Class: Users::ConfirmationsController
- Inherits:
-
Devise::ConfirmationsController
- Object
- Devise::ConfirmationsController
- Users::ConfirmationsController
- Defined in:
- app/controllers/users/confirmations_controller.rb
Instance Method Summary collapse
-
#create ⇒ Json
Json that contains wheter the email confirmation was sent or not.
- #show ⇒ Object
Instance Method Details
#create ⇒ Json
Returns Json that contains wheter the email confirmation was sent or not. If it is not successful, it returs an error message.
58 59 60 61 62 63 64 65 66 |
# File 'app/controllers/users/confirmations_controller.rb', line 58 def create super do |resource| if successfully_sent?(resource) return respond_with_successful else return respond_with_error(resource.errors..to_sentence) end end end |
#show ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'app/controllers/users/confirmations_controller.rb', line 4 def show # delete all previus messages flash.clear # get the confirmation token sent through get params token = params[:confirmation_token] # validate that token were sent if token.blank? return flash[:danger] = I18n.t("core.users/confirmations.messages_warning_invalid_token") end # check if token belongs to a unconfirmed user user = Lesli::User.find_by(:confirmation_token => token, :confirmed_at => nil) # validate that user were found if user.blank? return flash[:danger] = I18n.t("core.users/confirmations.messages_warning_invalid_token") end # register a log with a validation atempt for the user activity = user.activities.create({ title: "user_confirmation", description: "Confirmation process started" }) registration_operator = LesliShield::UserRegistrationOperator.new(user) # confirm the user registration_operator.confirm # let the user knows that the confirmation is done flash[:success] = I18n.t("core.users/confirmations.messages_success_email_updated") # if new account, launch account onboarding in another thread, # so the user can continue with the registration process registration_operator.create_account if user.account.blank? #Thread.new { registration_operator.create_account } if user.account.blank? end |