Class: RailsJwtAuth::ConfirmationsController

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

Instance Method Summary collapse

Methods included from RenderHelper

#render_204, #render_422, #render_registration, #render_session

Instance Method Details

#createObject



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

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

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

#updateObject



13
14
15
16
17
18
19
20
21
22
# File 'app/controllers/rails_jwt_auth/confirmations_controller.rb', line 13

def update
  if params[:confirmation_token].blank?
    return render_422(confirmation_token: [I18n.t('rails_jwt_auth.errors.not_found')])
  end

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

  user.confirm! ? render_204 : render_422(user.errors)
end