mirror of
https://github.com/we-promise/sure.git
synced 2026-04-18 19:44:09 +00:00
Add/remove members and invitations (#1744)
* Add/remove members and invitations * Lint
This commit is contained in:
@@ -4,4 +4,28 @@ class Settings::ProfilesController < SettingsController
|
||||
@users = Current.family.users.order(:created_at)
|
||||
@pending_invitations = Current.family.invitations.pending
|
||||
end
|
||||
|
||||
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
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user