Add logic to prevent the current user from removing himself from the administrator list, and a flash error notice for that scenario
This commit is contained in:
@@ -26,7 +26,12 @@ class Admin::AdministratorsController < Admin::BaseController
|
||||
end
|
||||
|
||||
def destroy
|
||||
@administrator.destroy
|
||||
if current_user.id == @administrator.user_id
|
||||
flash[:error] = I18n.t("admin.administrators.administrator.restricted_removal")
|
||||
else
|
||||
@administrator.destroy
|
||||
end
|
||||
|
||||
redirect_to admin_administrators_path
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user