Class: DoorMat::ForgotPasswordsController

Inherits:
ApplicationController show all
Defined in:
app/controllers/door_mat/forgot_passwords_controller.rb

Instance Method Summary collapse

Methods included from Controller

#config_url_redirect, #handle_unverified_request, #lockdown, #main_app_root_url, #protected_by_password_less_session, #require_confirmed_email, #require_password_reconfirm, #require_valid_session, #sign_out, #update_session_last_activity_time

Instance Method Details

#choose_new_passwordObject



24
25
26
27
# File 'app/controllers/door_mat/forgot_passwords_controller.rb', line 24

def choose_new_password
  @forgot_password = DoorMat::ForgotPassword.new(choose_new_password_params)
  @forgot_password.email = DoorMat::Email.decode_urlsafe(@forgot_password.email)
end

#createObject

:email is a Base64.urlsafe_encode64 of a user email address



10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'app/controllers/door_mat/forgot_passwords_controller.rb', line 10

def create
  @forgot_password = DoorMat::ForgotPassword.new(forgot_password_params)
  @forgot_password.password = @forgot_password.password_confirmation = '-'

  if @forgot_password.valid?
    DoorMat::Process::ResetPassword.for(@forgot_password.email, self)

    # No matter what, requester gets the same response
    redirect_to config_url_redirect(:forgot_password_verification_mail_sent_url)
  else
    render :new
  end
end

#newObject



5
6
7
# File 'app/controllers/door_mat/forgot_passwords_controller.rb', line 5

def new
  @forgot_password = DoorMat::ForgotPassword.new
end

#reset_passwordObject



29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'app/controllers/door_mat/forgot_passwords_controller.rb', line 29

def reset_password
  @forgot_password = DoorMat::ForgotPassword.new(reset_password_params)
  if @forgot_password.valid?
    if DoorMat::Process::ResetPassword.with(@forgot_password)
    redirect_to door_mat.
    else
      flash[:alert] = I18n.t('door_mat.forgot_password.make_new_request')
      redirect_to door_mat.forgot_password_url
    end

  else
    render :choose_new_password
  end
end