Aggiunge gestione account con cambio password su web e app.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-08-08 10:38:57 +02:00
co-authored by Cursor
parent b8694a6b7b
commit 83a804a709
46 changed files with 1591 additions and 34 deletions
@@ -0,0 +1,39 @@
module Users
class ChangePassword
Result = Struct.new(:ok?, :error, keyword_init: true)
def self.call(user:, current_password:, password:, password_confirmation:)
new(
user: user,
current_password: current_password,
password: password,
password_confirmation: password_confirmation
).call
end
def initialize(user:, current_password:, password:, password_confirmation:)
@user = user
@current_password = current_password.to_s
@password = password.to_s
@password_confirmation = password_confirmation.to_s
end
def call
unless @user.authenticate(@current_password)
return Result.new(ok?: false, error: :current_incorrect)
end
if @password.blank? || @password.length < 8
return Result.new(ok?: false, error: :too_short)
end
if @password != @password_confirmation
return Result.new(ok?: false, error: :mismatch)
end
@user.update!(password: @password)
@user.clear_password_reset!
Result.new(ok?: true)
end
end
end