Class: Authorizme::PasswordResetsController

Inherits:
AuthorizmeController show all
Defined in:
app/controllers/authorizme/password_resets_controller.rb

Instance Method Summary collapse

Methods inherited from AuthorizmeController

#index

Instance Method Details

#createObject



6
7
8
9
10
11
12
13
14
# File 'app/controllers/authorizme/password_resets_controller.rb', line 6

def create
  user = User.find_by_email(params[:email])
  user.send_password_reset if user
  if user
    respond_with user, :location => root_url
  else
    respond_with nil, :location => root_url
  end
end

#editObject



16
17
18
# File 'app/controllers/authorizme/password_resets_controller.rb', line 16

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

#newObject



3
4
# File 'app/controllers/authorizme/password_resets_controller.rb', line 3

def new
end

#updateObject



20
21
22
23
24
25
26
27
28
29
30
31
# File 'app/controllers/authorizme/password_resets_controller.rb', line 20

def update
  @user = User.find_by_password_reset_token!(params[:id])
  @user.password_will_be_update_in_this_request if @user
  if @user.password_reset_sent_at < 2.hours.ago
    respond_with @user, :location => root_url, :alert => "Password reset has expired." 
  elsif @user.update_attributes(params[:user])
     @user
    respond_with @user, :location => root_url, :notice => "Password has been reset!"
  else
    render :edit
  end
end