From: Stéphane Jacob Date: Wed, 21 Sep 2011 15:31:27 +0000 (+0200) Subject: User addition to groups sshould be more consistant now. X-Git-Tag: xorg/1.1.4~142 X-Git-Url: http://git.polytechnique.org/?a=commitdiff_plain;h=79ba15556f19e9cce0fb0f3cbd3873dfd240db87;p=platal.git User addition to groups sshould be more consistant now. Signed-off-by: Stéphane Jacob --- diff --git a/modules/xnetgrp.php b/modules/xnetgrp.php index e6099e5..b5f5e57 100644 --- a/modules/xnetgrp.php +++ b/modules/xnetgrp.php @@ -850,20 +850,10 @@ class XnetGrpModule extends PLModule // + (the data) => %2B (in the url) => + (first decoding) => ' ' (second decoding) // Since there can be no spaces in emails, we can fix this with : $email = str_replace(' ', '+', $email); + $is_valid_email = isvalid_email($email); - // Finds or creates account: first cases are for users with an account. - if (!User::isForeignEmailAddress($email)) { - // Standard account - $user = User::getSilent($email); - } else if (!isvalid_email($email)) { - // email might not be a regular email but an alias or a hruid - $user = User::getSilent($email); - if (!$user) { - // need a valid email address - $page->trigError('« ' . $email . ' Â» n\'est pas une adresse email valide.'); - return; - } - } else if (Env::v('x') && Env::i('userid')) { + // X not registered to main site. + if (Env::v('x') && Env::i('userid') && $is_valid_email) { $user = User::getSilentWithUID(Env::i('userid')); if (!$user) { $page->trigError('Utilisateur invalide.'); @@ -888,9 +878,15 @@ class XnetGrpModule extends PLModule } } } else { - // Check if the email is a redirection. $user = User::getSilent($email); + // Wrong email and no user: failure. + if (is_null($user) && !$is_valid_email) { + $page->trigError('« ' . $email . ' Â» n\'est pas une adresse email valide.'); + return; + } + + // Deals with xnet accounts. if (is_null($user) || $user->type == 'xnet') { // User is of type xnet. There are 3 possible cases: // * the email is not known yet: we create a new account and