Class: Searls::Auth::ResetsPasswordsController

Inherits:
BaseController
  • Object
show all
Defined in:
app/controllers/searls/auth/resets_passwords_controller.rb

Instance Method Summary collapse

Methods inherited from BaseController

#forwardable_params

Instance Method Details

#showObject



8
9
10
11
12
# File 'app/controllers/searls/auth/resets_passwords_controller.rb', line 8

def show
  @token = params[:token]
  @user_email = @user.email
  render Searls::Auth.config.password_reset_edit_view, layout: Searls::Auth.config.layout
end

#updateObject



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'app/controllers/searls/auth/resets_passwords_controller.rb', line 14

def update
  result = ResetsPassword.new.reset(
    user: @user,
    password: params[:password],
    password_confirmation: params[:password_confirmation]
  )

  if result.success?
    handle_successful_reset(result.user)
  else
    flash.now[:alert] = Array(result.errors).first
    @token = params[:token]
    @user_email = @user.email
    render Searls::Auth.config.password_reset_edit_view, layout: Searls::Auth.config.layout, status: :unprocessable_content
  end
end