Class: RailsJwtAuth::ProfilesController

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

Constant Summary collapse

PASSWORD_PARAMS =
%i[current_password password password_confirmation].freeze

Instance Method Summary collapse

Methods included from RenderHelper

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

Methods included from AuthenticableHelper

#authenticate, #authenticate!, #current_user, #get_jwt_from_request, #jwt_payload, #signed_in?, #track_request, #unauthorize!

Instance Method Details

#emailObject



31
32
33
34
35
36
37
38
39
# File 'app/controllers/rails_jwt_auth/profiles_controller.rb', line 31

def email
  return update unless current_user.is_a?(RailsJwtAuth::Confirmable)

  if current_user.update_email(profile_update_email_params)
    render_204
  else
    render_422(current_user.errors.details)
  end
end

#passwordObject



23
24
25
26
27
28
29
# File 'app/controllers/rails_jwt_auth/profiles_controller.rb', line 23

def password
  if current_user.update_password(update_password_params)
    render_204
  else
    render_422(current_user.errors.details)
  end
end

#showObject



11
12
13
# File 'app/controllers/rails_jwt_auth/profiles_controller.rb', line 11

def show
  render_profile current_user
end

#updateObject



15
16
17
18
19
20
21
# File 'app/controllers/rails_jwt_auth/profiles_controller.rb', line 15

def update
  if current_user.update(profile_update_params)
    render_204
  else
    render_422(current_user.errors.details)
  end
end