Class: RailsJwtAuth::PasswordsController

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

Instance Method Summary collapse

Methods included from RenderHelper

#render_201, #render_204, #render_422

Instance Method Details

#createObject



5
6
7
8
9
10
# File 'app/controllers/rails_jwt_auth/passwords_controller.rb', line 5

def create
  user = RailsJwtAuth.model.where(email: create_password_params[:email]).first
  return render_422(email: [I18n.t('rails_jwt_auth.errors.not_found')]) unless user

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

#updateObject



12
13
14
15
16
17
# File 'app/controllers/rails_jwt_auth/passwords_controller.rb', line 12

def update
  user = RailsJwtAuth.model.where(reset_password_token: params[:reset_password_token]).first
  return render_422(reset_password_token: [I18n.t('rails_jwt_auth.errors.not_found')]) unless user

  user.update_attributes(update_password_params) ? render_204 : render_422(user.errors)
end