Class: RailsJwtAuth::PasswordsController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- RailsJwtAuth::PasswordsController
show all
- Includes:
- ParamsHelper, RenderHelper
- Defined in:
- app/controllers/rails_jwt_auth/passwords_controller.rb
Instance Method Summary
collapse
#render_204, #render_422, #render_registration, #render_session
Instance Method Details
#create ⇒ Object
6
7
8
9
10
11
|
# File 'app/controllers/rails_jwt_auth/passwords_controller.rb', line 6
def create
user = RailsJwtAuth.model.where(email: password_create_params[:email].to_s.downcase).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
|
#update ⇒ Object
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
# File 'app/controllers/rails_jwt_auth/passwords_controller.rb', line 13
def update
if params[:reset_password_token].blank?
return render_422(reset_password_token: [I18n.t('rails_jwt_auth.errors.not_found')])
end
user = RailsJwtAuth.model.where(reset_password_token: params[:reset_password_token]).first
unless user
return render_422(reset_password_token: [I18n.t('rails_jwt_auth.errors.not_found')])
end
unless password_update_params[:password].present?
return render_422(password: [I18n.t('rails_jwt_auth.errors.password.blank')])
end
user.update_attributes(password_update_params) ? render_204 : render_422(user.errors)
end
|