Class: PasswordResetsController

Inherits:
ApplicationController
  • Object
show all
Defined in:
app/controllers/password_resets_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject



3
4
5
6
7
8
9
10
11
# File 'app/controllers/password_resets_controller.rb', line 3

def create
  user = User.find_by_email(params[:email])
  if user
    user.send_password_reset
    redirect_to root_url, :notice => t('authentication.reset_password_email_sent_confirmation')
  else
    redirect_to root_url, :alert => t('authentication.warning.no_such_email')
  end
end

#editObject



13
14
15
# File 'app/controllers/password_resets_controller.rb', line 13

def edit
  @user = User.find_by_password_reset_token!(params[:id])
end

#updateObject



17
18
19
20
21
22
23
24
25
26
# File 'app/controllers/password_resets_controller.rb', line 17

def update
  @user = User.find_by_password_reset_token!(params[:id])
  if @user.password_reset_sent_at < 24.hours.ago
    redirect_to new_password_reset_path, :alert => t('authentication.warning.password_reset_expired')
  elsif @user.update_attributes(params[:user])
    redirect_to root_url, :notice => t('authentication.password_reset_confirmation')
  else
    render :edit
  end
end