2025-02-21 11:57:59 -05:00
|
|
|
class Settings::ProfilesController < ApplicationController
|
|
|
|
layout "settings"
|
|
|
|
|
2024-04-18 07:56:51 -04:00
|
|
|
def show
|
2024-10-23 11:20:55 -04:00
|
|
|
@user = Current.user
|
2024-11-01 10:23:27 -05:00
|
|
|
@users = Current.family.users.order(:created_at)
|
|
|
|
@pending_invitations = Current.family.invitations.pending
|
2024-02-05 22:19:23 +08:00
|
|
|
end
|
2025-01-30 13:13:37 -06:00
|
|
|
|
|
|
|
def destroy
|
|
|
|
unless Current.user.admin?
|
|
|
|
flash[:alert] = t("settings.profiles.destroy.not_authorized")
|
|
|
|
redirect_to settings_profile_path
|
|
|
|
return
|
|
|
|
end
|
|
|
|
|
|
|
|
@user = Current.family.users.find(params[:user_id])
|
|
|
|
|
|
|
|
if @user == Current.user
|
|
|
|
flash[:alert] = t("settings.profiles.destroy.cannot_remove_self")
|
|
|
|
redirect_to settings_profile_path
|
|
|
|
return
|
|
|
|
end
|
|
|
|
|
|
|
|
if @user.destroy
|
|
|
|
flash[:notice] = t("settings.profiles.destroy.member_removed")
|
|
|
|
else
|
|
|
|
flash[:alert] = t("settings.profiles.destroy.member_removal_failed")
|
|
|
|
end
|
|
|
|
|
|
|
|
redirect_to settings_profile_path
|
|
|
|
end
|
2024-02-05 22:19:23 +08:00
|
|
|
end
|