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
|
end
|
||||||
|
|
||||||
def destroy
|
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
|
redirect_to admin_administrators_path
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -233,6 +233,7 @@ en:
|
|||||||
administrator:
|
administrator:
|
||||||
add: Add
|
add: Add
|
||||||
delete: Delete
|
delete: Delete
|
||||||
|
restricted_removal: "Sorry, you can't remove yourself from the administrators"
|
||||||
search:
|
search:
|
||||||
email_placeholder: Search user by email
|
email_placeholder: Search user by email
|
||||||
search: Search
|
search: Search
|
||||||
|
|||||||
@@ -187,6 +187,7 @@ es:
|
|||||||
administrator:
|
administrator:
|
||||||
add: Añadir como Administrador
|
add: Añadir como Administrador
|
||||||
delete: Borrar
|
delete: Borrar
|
||||||
|
restricted_removal: "Lo sentimos, no puedes te eliminar a ti mismo de la lista"
|
||||||
search:
|
search:
|
||||||
email_placeholder: Buscar usuario por email
|
email_placeholder: Buscar usuario por email
|
||||||
search: Buscar
|
search: Buscar
|
||||||
|
|||||||
Reference in New Issue
Block a user