From: Nicolas Iooss Date: Sun, 1 Jun 2014 19:44:19 +0000 (+0200) Subject: Don't set a default account type when creating an ext account X-Git-Tag: xorg/1.1.13~12 X-Git-Url: http://git.polytechnique.org/?p=platal.git;a=commitdiff_plain;h=de04c29a5464e6ed6dc0e11a6556ad1c19efd7c4 Don't set a default account type when creating an ext account In the form to add a new "external account", the type "Personnel de l'AX" is selected by default, which may lead to incorrect account hruid when an admin forgets to change this type. To prevent this issue, a new empty type is added in the HTML form. --- diff --git a/modules/admin.php b/modules/admin.php index d4f1390..a220bcc 100644 --- a/modules/admin.php +++ b/modules/admin.php @@ -1515,12 +1515,14 @@ class AdminModule extends PLModule $sex = Post::s('sex'); $email = Post::t('email'); $type = Post::s('type'); - $login = PlUser::makeHrid($firstname, $lastname, $type); - if (!isvalid_email($email)) { + if (!$type) { + $page->trigError("Empty account type"); + } elseif (!isvalid_email($email)) { $page->trigError("Invalid email address: $email"); - } else if (strlen(Post::s('pwhash')) != 40) { + } elseif (strlen(Post::s('pwhash')) != 40) { $page->trigError("Invalid password hash"); } else { + $login = PlUser::makeHrid($firstname, $lastname, $type); $full_name = $firstname . ' ' . $lastname; $directory_name = $lastname . ' ' . $firstname; XDB::execute("INSERT INTO accounts (hruid, type, state, password, diff --git a/templates/admin/accounts.tpl b/templates/admin/accounts.tpl index a4a91b9..6d1a619 100644 --- a/templates/admin/accounts.tpl +++ b/templates/admin/accounts.tpl @@ -75,6 +75,7 @@ function add_user_to_url(f) { Type de compte