Class: RailsJwtAuth::ResetPasswordsController

Inherits:
ApplicationController
  • Object
show all
Includes:
ParamsHelper, RenderHelper
Defined in:
app/controllers/rails_jwt_auth/reset_passwords_controller.rb

Instance Method Summary collapse

Methods included from RenderHelper

#render_204, #render_404, #render_410, #render_422, #render_profile, #render_registration, #render_session

Instance Method Details

#createObject

used to request restore password



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

def create
  unless @user
    if RailsJwtAuth.avoid_email_errors
      return render_204
    else
      return render_422(RailsJwtAuth.email_field_name => [{error: :not_found}])
    end
  end

  @user.send_reset_password_instructions ? render_204 : render_422(@user.errors.details)
end

#showObject

used to verify token



10
11
12
13
14
15
16
17
18
# File 'app/controllers/rails_jwt_auth/reset_passwords_controller.rb', line 10

def show
  return render_404 unless @user

  if @user.reset_password_sent_at < RailsJwtAuth.reset_password_expiration_time.ago
    return render_410
  end

  render_204
end

#updateObject

used to set new password



34
35
36
37
38
39
40
41
42
# File 'app/controllers/rails_jwt_auth/reset_passwords_controller.rb', line 34

def update
  return render_404 unless @user

  if @user.set_reset_password(reset_password_update_params)
    render_204
  else
    render_422(@user.errors.details)
  end
end