Class: MerbAuthSlicePasswordReset::Passwords

Inherits:
Application
  • Object
show all
Defined in:
app/controllers/passwords.rb

Instance Method Summary collapse

Instance Method Details

#forgot_passwordObject



3
4
5
6
# File 'app/controllers/passwords.rb', line 3

def forgot_password
  @login_param_name = Merb::Authentication::Strategies::Basic::Base.
  render
end

#resetObject

Raises:

  • (NotFound)


20
21
22
23
24
# File 'app/controllers/passwords.rb', line 20

def reset
  @user = Merb::Authentication.user_class.find_with_password_reset_code(params[:password_reset_code])
  raise NotFound if @user.nil?
  render
end

#reset_checkObject

Raises:

  • (NotFound)


26
27
28
29
30
31
32
33
34
35
36
37
# File 'app/controllers/passwords.rb', line 26

def reset_check
  @user = Merb::Authentication.user_class.find_with_password_reset_code(params[:password_reset_code])
  # FIXME: This only works for DataMapper right now.  I assume that the ActiveORM abstraction
  #        will have a method that works for all ORMs.
  raise NotFound if @user.nil?
  if @user.update(params[:user])
    redirect_after_password_reset
  else
    message[:error] = @user.errors.map { |e| e.to_s }.join(" and ") if @user.errors
    render :reset
  end
end

#send_confirmationObject



8
9
10
11
12
13
14
15
16
17
18
# File 'app/controllers/passwords.rb', line 8

def send_confirmation
  @login_param_name = Merb::Authentication::Strategies::Basic::Base.
  @user = Merb::Authentication.user_class.(@login_param_name, params[@login_param_name])
  if @user
    @user.send_password_reset_notification
    redirect_after_sending_confirmation
  else
    message[:error] = "User with #{@login_param_name} \"%s\" not found".t(params[@login_param_name].freeze)
    render :forgot_password
  end
end