How can I sign out a devise user from the Rails console?
Devise provides helper methods to do these things: user = User.find(params[:id]) sign_in user sign_out user Hope this helps.
Devise provides helper methods to do these things: user = User.find(params[:id]) sign_in user sign_out user Hope this helps.
Ryan is correct in that the default Devise gem does not support both the :rememberable and :timeoutable options. However, like all things Ruby, if you don’t like the decision that some other coder has made, especially when it strays from the norm that most users are likely to expect, then you can simply override it. … Read more
A simple way to have just one step for users to confirm email address and set initial password using the link you proposed… Send one email your app generates, including a reset_password_token, and consider user’s possession of that token confirmation of the validity of that email address. In system account generation code, assuming User model … Read more
With Devise 1.1.3 the following should work devise_for :user, :path => ”, :path_names => { :sign_in => “login”, :sign_out => “logout”, :sign_up => “register” } The routes it creates will not be appended with “/user/…” because of the :path parameter being an empty string. The :pathnames hash will take care of naming the routes as … Read more
So upgrading to Devise 3.1.0 left some ‘cruft’ in a view that I hadn’t touched in a while. According to this blog post, you need to change your Devise mailer to use @token instead of the old @resource.confirmation_token. Find this in app/views/<user>/mailer/confirmation_instructions.html.erb and change it to something like: <p>Welcome <%= @resource.email %>!</p> <p>You can confirm … Read more
Jimbo did an awesome job explaining the “why” behind the issue you’re running into. There are two approaches you can take to resolve the issue: (As recommended by Jimbo) Override Devise::SessionsController to return the new csrf-token: class SessionsController < Devise::SessionsController def destroy # Assumes only JSON requests signed_out = (Devise.sign_out_all_scopes ? sign_out : sign_out(resource_name)) render … Read more
Simply add after_filter in ApplicationController after_filter :user_activity private def user_activity current_user.try :touch end Then in user model add online? method def online? updated_at > 10.minutes.ago end Also u can create scope scope :online, lambda{ where(“updated_at > ?”, 10.minutes.ago) }
There is a devise configuration called :token_authenticatable. So if you add that to the devise method in your “user”, then you can authenticate in your API just by calling “/api/v1/recipes?qs=sweet&auth_token=[@user.auth_token]” You’ll probably want this in your user as well: before_save :ensure_authentication_token UPDATE (with API authorization code) The method you’re looking for are: resource = User.find_for_database_authentication(:login=>params[:user_login][:login]) … Read more
Yup. I feel dumb. If anyone else is having a similarly vapid moment. Just use the rails console to create the admin user: ➡ rails c Loading development environment (Rails 3.0.0.beta3) irb(main):001:0> admin = Admin.create! do |u| irb(main):002:1* u.email=”sample@sample.com” irb(main):003:1> u.password = ‘password’ irb(main):004:1> u.password_confirmation = ‘password’ irb(main):005:1> end That will do it. Now just … Read more
To disable password confirmation you can simply remove the password_confirmation field from the registration form. This disables the need to confirm the password entirely! Generate devise views if you haven’t: rails g devise:views Remove the password_confirmation section in app\views\devise\registrations\new.html.erb The reason why this works lies in lib/devise/models/validatable.rb in the Devise source: module Devise module Models … Read more