Class: Devise::PasswordExpiredController

Inherits:
DeviseController
  • Object
show all
Defined in:
app/controllers/devise/password_expired_controller.rb

Instance Method Summary collapse

Instance Method Details

#after_password_expired_update_path_for(_resource) ⇒ String, Symbol

Allows you to customize where the user is sent to after the update action successfully completes.

Defaults to the request’s original path, and then ‘root` if that is `nil`.

Parameters:

  • resource (ActiveModel::Model)

    Devise ‘resource` model for logged in user.

Returns:

  • (String, Symbol)

    The path that the user will be sent to.



42
43
44
# File 'app/controllers/devise/password_expired_controller.rb', line 42

def after_password_expired_update_path_for(_resource)
  stored_location_for(scope) || :root
end

#showObject



9
10
11
# File 'app/controllers/devise/password_expired_controller.rb', line 9

def show
  respond_with(resource)
end

#updateObject

Note:

if a common data format like :json or :xml are requested this will respond with a 204 No Content and set the Location header. Useful for dealing with APIs when JS clients would otherwise automatically follow the redirect, which can be problematic.

Update the password stored on the ‘resource`.



21
22
23
24
25
26
27
28
29
30
31
32
# File 'app/controllers/devise/password_expired_controller.rb', line 21

def update
  resource.extend(Devise::Models::DatabaseAuthenticatablePatch)
  if resource.update_with_password(resource_params)
    warden.session(scope)['password_expired'] = false
    set_flash_message :notice, :updated
     resource, scope: scope
    respond_with({}, location: after_password_expired_update_path_for(resource))
  else
    clean_up_passwords(resource)
    respond_with(resource, action: :show)
  end
end