2018-05-31 15:18:06 +02:00
|
|
|
module Manager
|
|
|
|
class UsersController < Manager::ApplicationController
|
2020-01-13 14:35:25 +01:00
|
|
|
def update
|
|
|
|
user = User.find(params[:id])
|
|
|
|
new_email = params[:user][:email]
|
|
|
|
user.skip_reconfirmation!
|
|
|
|
user.update(email: new_email)
|
|
|
|
if (user.valid?)
|
|
|
|
flash[:notice] = "L'email a été modifié en « #{new_email} » sans notification ni validation par email."
|
|
|
|
else
|
|
|
|
flash[:error] = "« #{new_email} » n'est pas une adresse valide."
|
|
|
|
end
|
|
|
|
redirect_to edit_manager_user_path(user)
|
|
|
|
end
|
|
|
|
|
2018-07-17 12:10:56 +02:00
|
|
|
def resend_confirmation_instructions
|
|
|
|
user = User.find(params[:id])
|
|
|
|
user.resend_confirmation_instructions
|
2018-09-19 15:05:26 +02:00
|
|
|
flash[:notice] = "L'email d'activation de votre compte a été renvoyé."
|
2018-07-17 12:10:56 +02:00
|
|
|
redirect_to manager_user_path(user)
|
|
|
|
end
|
2019-07-04 12:36:17 +02:00
|
|
|
|
|
|
|
def enable_feature
|
|
|
|
user = User.find(params[:id])
|
|
|
|
|
|
|
|
params[:features].each do |key, enable|
|
|
|
|
if enable
|
|
|
|
Flipper.enable_actor(key.to_sym, user)
|
|
|
|
else
|
|
|
|
Flipper.disable_actor(key.to_sym, user)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
head :ok
|
|
|
|
end
|
2020-01-08 10:50:16 +01:00
|
|
|
|
|
|
|
def delete
|
|
|
|
user = User.find(params[:id])
|
|
|
|
if !user.can_be_deleted?
|
2020-01-30 10:48:28 +01:00
|
|
|
fail "Impossible de supprimer cet utilisateur. Il a des dossiers en instruction ou il est administrateur."
|
2020-01-08 10:50:16 +01:00
|
|
|
end
|
|
|
|
user.delete_and_keep_track_dossiers(current_administration)
|
|
|
|
|
|
|
|
logger.info("L'utilisateur #{user.id} est supprimé par #{current_administration.id}")
|
|
|
|
flash[:notice] = "L'utilisateur #{user.id} est supprimé"
|
|
|
|
|
|
|
|
redirect_to manager_users_path
|
|
|
|
end
|
2018-05-31 15:18:06 +02:00
|
|
|
end
|
|
|
|
end
|