Files
fizzy/app/controllers/users_controller.rb
T
Mike Dalessio c388f5ef20 Display validation errors for user profiles.
Specifically this will help people understand why their SVG avatar
uploads are being rejected, and will keep the RecordInvalid exception
out of Sentry logs.
2025-12-06 14:34:08 -05:00

37 lines
686 B
Ruby

class UsersController < ApplicationController
before_action :set_user
before_action :ensure_permission_to_change_user, only: %i[ update destroy ]
def show
end
def edit
end
def update
if @user.update(user_params)
redirect_to @user
else
render :edit, status: :unprocessable_entity
end
end
def destroy
@user.deactivate
redirect_to users_path
end
private
def set_user
@user = Current.account.users.active.find(params[:id])
end
def ensure_permission_to_change_user
head :forbidden unless Current.user.can_change?(@user)
end
def user_params
params.expect(user: [ :name, :avatar ])
end
end