Fix account page forms & add account actions rspec
All checks were successful
CI / scan_ruby (push) Successful in 21s
CI / scan_js (push) Successful in 13s
CI / lint (push) Successful in 13s
CI / test (push) Successful in 37s

#5
This commit is contained in:
sto
2025-12-10 10:44:03 +01:00
parent cce090587a
commit 8cea403dc9
12 changed files with 131 additions and 47 deletions

View File

@@ -19,6 +19,7 @@ class UsersController < ApplicationController
def update
authorize @user
@user.password_change_attempt = false
if @user.update(user_params)
redirect_to contests_path, notice: t("users.edit.notice")
else
@@ -26,6 +27,18 @@ class UsersController < ApplicationController
end
end
def change_password
@user = User.find(params[:user_id])
authorize @user
@user.password_change_attempt = true
if @user.update(user_password_params)
redirect_to contests_path, notice: t("users.edit.notice")
else
render :edit, status: :unprocessable_entity
end
end
def show
authorize @user
@@ -89,6 +102,10 @@ class UsersController < ApplicationController
end
def user_params
params.expect(user: [ :username, :email_address, :lang, :password ])
params.expect(user: [ :username, :email_address, :lang ])
end
def user_password_params
params.expect(user: [ :password ])
end
end