Class: QuoVadis::PasswordResetsController

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

Instance Method Summary collapse

Instance Method Details

#createObject



15
16
17
18
19
20
21
22
23
24
# File 'app/controllers/quo_vadis/password_resets_controller.rb', line 15

def create
   = QuoVadis. params

  if 
    token = QuoVadis::PasswordResetToken.generate 
    QuoVadis.deliver :reset_password, {email: .model.email, url: quo_vadis.password_reset_url(token)}
  end

  redirect_to password_resets_path, notice: QuoVadis.translate('flash.password_reset.create')
end

#editObject

emailed password-reset link points here



28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'app/controllers/quo_vadis/password_resets_controller.rb', line 28

def edit
   = PasswordResetToken. params[:token]

  unless   # expired or password already changed
    redirect_to new_password_reset_path, alert: QuoVadis.translate('flash.password_reset.unknown') and return
  end

  # Ensure the flash notice set in the create action does not appear when the user clicks the
  # link in the email they were sent.
  flash.delete :notice

  @password = QuoVadis::Password.new
end

#indexObject

holding page for after the create action



7
8
# File 'app/controllers/quo_vadis/password_resets_controller.rb', line 7

def index
end

#newObject



11
12
# File 'app/controllers/quo_vadis/password_resets_controller.rb', line 11

def new
end

#updateObject

really reset the password



44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# File 'app/controllers/quo_vadis/password_resets_controller.rb', line 44

def update
   = PasswordResetToken. params[:token]

  unless   # expired or password already changed
    redirect_to new_password_reset_path, alert: QuoVadis.translate('flash.password_reset.unknown') and return
  end

  @password = .password
  if @password.reset params[:password][:password], params[:password][:password_confirmation]
    # Logout account's sessions because password has changed.
    # Note model is not logged in here.
    @password..sessions.destroy_all

    qv.log @password., Log::PASSWORD_RESET
    QuoVadis.notify :password_reset_notification, email: @password..model.email

     @password..model, true
    redirect_to qv.path_after_authentication, notice: QuoVadis.translate('flash.password_reset.reset')
  else
    render :edit, status: :unprocessable_entity
  end
end