From 14dede1a74de8912048c9f63a11a17ed88b86e06 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 10 Jan 2013 21:32:10 +0100 Subject: [PATCH] Fix: Protection to avoid renaming a user with a login that already exists. --- htdocs/user/fiche.php | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/htdocs/user/fiche.php b/htdocs/user/fiche.php index e3d6236ff4a..607ed452657 100644 --- a/htdocs/user/fiche.php +++ b/htdocs/user/fiche.php @@ -307,9 +307,27 @@ if ($action == 'update' && ! $_POST["cancel"]) if (! $error) { - $db->begin(); $object->fetch($id); + // Test if new login + if (GETPOST("login") && GETPOST("login") != $object->login) + { + dol_syslog("New login ".$object->login." is requested. We test it does not exists."); + $tmpuser=new User($db); + $result=$tmpuser->fetch(0, GETPOST("login")); + if ($result > 0) + { + $message='
'.$langs->trans("ErrorLoginAlreadyExists").'
'; + $action="edit"; // Go back to create page + $error++; + } + } + } + + if (! $error) + { + $db->begin(); + $object->oldcopy=dol_clone($object); $object->lastname = GETPOST("nom");