Sha256: b8a5fe5c182ac4c1880f9e178a1683c7085ae4be6dc142b4782e8b6136a20c31

Contents?: true

Size: 923 Bytes

Versions: 2

Compression:

Stored size: 923 Bytes

Contents

class Devise::PasswordExpiredController < DeviseController
  skip_before_filter :handle_password_change
  prepend_before_filter :authenticate_scope!, :only => [:show, :update]

  def show
    if not resource.nil? and resource.need_change_password?
      render_with_scope :show
    else
      redirect_to :root
    end
  end

  def update
    resource.extend(Devise::Models::DatabaseAuthenticatablePatch)
    if resource.update_with_password(params[resource_name])
      warden.session(scope)[:password_expired] = false
      set_flash_message :notice, :updated
      sign_in scope, resource
      redirect_to stored_location_for(scope) || :root
    else
      clean_up_passwords(resource)
      render_with_scope :show
    end
  end

  private

  def scope
    resource_name.to_sym
  end

  def authenticate_scope!
    send(:"authenticate_#{resource_name}!")
    self.resource = send("current_#{resource_name}")
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
devise_password_expirable-3.0.0 app/controllers/devise/password_expired_controller.rb
devise_password_expirable-2.0.0 app/controllers/devise/password_expired_controller.rb