Class: PasswordsController

Inherits:
Devise::PasswordsController
  • Object
show all
Defined in:
app/controllers/passwords_controller.rb

Instance Method Summary collapse

Instance Method Details

#editObject


6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'app/controllers/passwords_controller.rb', line 6

def edit
  super
  reset_password_token = Devise.token_generator.digest(
    User,
    :reset_password_token,
    resource.reset_password_token
  )

  unless reset_password_token.nil?
    user = User.where(
      reset_password_token: reset_password_token
    ).first_or_initialize

    unless user.reset_password_period_valid?
      flash[:alert] = 'Your password reset token has expired.'
      redirect_to(new_user_password_url(user_email: user['email']))
    end
  end
end

#updateObject


26
27
28
29
30
31
32
# File 'app/controllers/passwords_controller.rb', line 26

def update
  super do |resource|
    if resource.valid? && resource.require_password?
      resource.update_attribute(:password_automatically_set, false)
    end
  end
end