@@ -40,19 +40,22 class AccountController < ApplicationController | |||||
40 | redirect_to home_url |
|
40 | redirect_to home_url | |
41 | end |
|
41 | end | |
42 |
|
42 | |||
43 |
# |
|
43 | # Lets user choose a new password | |
44 | def lost_password |
|
44 | def lost_password | |
45 | redirect_to(home_url) && return unless Setting.lost_password? |
|
45 | redirect_to(home_url) && return unless Setting.lost_password? | |
46 | if params[:token] |
|
46 | if params[:token] | |
47 | @token = Token.find_by_action_and_value("recovery", params[:token]) |
|
47 | @token = Token.find_by_action_and_value("recovery", params[:token].to_s) | |
48 | redirect_to(home_url) && return unless @token and !@token.expired? |
|
48 | if @token.nil? || @token.expired? | |
|
49 | redirect_to home_url | |||
|
50 | return | |||
|
51 | end | |||
49 | @user = @token.user |
|
52 | @user = @token.user | |
50 | if request.post? |
|
53 | if request.post? | |
51 | @user.password, @user.password_confirmation = params[:new_password], params[:new_password_confirmation] |
|
54 | @user.password, @user.password_confirmation = params[:new_password], params[:new_password_confirmation] | |
52 | if @user.save |
|
55 | if @user.save | |
53 | @token.destroy |
|
56 | @token.destroy | |
54 | flash[:notice] = l(:notice_account_password_updated) |
|
57 | flash[:notice] = l(:notice_account_password_updated) | |
55 |
redirect_to |
|
58 | redirect_to signin_path | |
56 | return |
|
59 | return | |
57 | end |
|
60 | end | |
58 | end |
|
61 | end |
General Comments 0
You need to be logged in to leave comments.
Login now