Method: Devise::Controllers::Helpers#sign_in
- Defined in:
- lib/devise/controllers/helpers.rb
#sign_in(resource_or_scope, *args) ⇒ Object
Sign in a user that already was authenticated. This helper is useful for logging users in after sign up.
All options given to sign_in is passed forward to the set_user method in warden. The only exception is the :bypass option, which bypass warden callbacks and stores the user straight in session. This option is useful in cases the user is already signed in, but we want to refresh the credentials in session.
Examples:
sign_in :user, @user # sign_in(scope, resource)
sign_in @user # sign_in(resource)
sign_in @user, :event => :authentication # sign_in(resource, options)
sign_in @user, :bypass => true # sign_in(resource, options)
109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 |
# File 'lib/devise/controllers/helpers.rb', line 109 def sign_in(resource_or_scope, *args) = args. scope = Devise::Mapping.find_scope!(resource_or_scope) resource = args.last || resource_or_scope expire_session_data_after_sign_in! if [:bypass] warden.session_serializer.store(resource, scope) elsif warden.user(scope) == resource && !.delete(:force) # Do nothing. User already signed in and we are not forcing it. true else warden.set_user(resource, .merge!(:scope => scope)) end end |