Class: Users::ConfirmationsController
- Inherits:
-
Devise::ConfirmationsController
- Object
- Devise::ConfirmationsController
- Users::ConfirmationsController
- Defined in:
- app/controllers/users/confirmations_controller.rb
Overview
Lesli
Copyright © 2026, Lesli Technologies, S. A.
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program. If not, see www.gnu.org/licenses/.
Lesli · Ruby on Rails SaaS Development Framework.
Made with ♥ by LesliTech Building a better future, one line of code at a time.
// · ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ // ·
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.
92 93 94 95 96 97 98 99 100 |
# File 'app/controllers/users/confirmations_controller.rb', line 92 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
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
# File 'app/controllers/users/confirmations_controller.rb', line 36 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 log = user.log(engine: LesliShield, source: self.class.name, action: action_name, operation: "user_confirmation", description: "Confirmation process started") # create a new instance of the registration service registration_service = LesliShield::UserRegistrationService.new(user) # confirm the user registration_service.confirm # send a welcome email to user as is confirmed LesliShield::DeviseMailer.with(user: resource).welcome.deliver_later # let the user knows that the confirmation is done flash[:success] = I18n.t("core.users/confirmations.messages_success_email_updated") # setup the new account registration_service.create_account if user.account.blank? log.update(description: 'User confirmed successfully') if defined?(LesliAudit) end |