Class: Users::PasswordsController

Inherits:
Devise::PasswordsController
  • Object
show all
Defined in:
app/controllers/users/passwords_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

Instance Method Details

#createObject

Sends an email with a token, so the user can reset their password



38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# File 'app/controllers/users/passwords_controller.rb', line 38

def create
    self.resource = resource_class.send_reset_password_instructions(resource_params)

    user = self.resource

    if successfully_sent?(resource)

        user.log(
            :engine => LesliShield, 
            :source => self.class.name, 
            :action => action_name, 
            :operation => 'password_reset', 
            :description => 'Reset password instructions sent'
        )

        success(I18n.t("core.users/passwords.messages_success"))
        redirect_to(new_user_password_path)
    else
        #respond_with(resource)
        danger("Error sending reset password instructions")
        redirect_to(new_user_password_path)
    end
end

#updateObject



62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
# File 'app/controllers/users/passwords_controller.rb', line 62

def update
    super do |user|

        logs = user.log(engine: LesliShield, source: self.class.name, action: action_name, operation: 'password_update', description:"Password update attempt")

        # check if password update was ok
        if user.errors.empty?

            # reset password expiration due the user just updated his password
            if user.has_expired_password?
                user.update(password_expiration_at: nil)
            end

            logs&.update(description: "Password update successful")
        else
            danger(user.errors.full_messages.to_sentence)
            logs&.update(description: resource.errors.full_messages.to_sentence)
        end
    end
end