From 8a0908db6bddf4160806d94c775ca7363447d67f Mon Sep 17 00:00:00 2001 From: =?utf8?q?St=C3=A9phane=20Jacob?= Date: Wed, 4 May 2011 16:57:49 +0200 Subject: [PATCH] Xnet users should login with their curretn email address. MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Stéphane Jacob --- bin/cron/cron_xnet_accounts.php | 2 +- classes/xnetsession.php | 7 ++++--- classes/xorgsession.php | 9 +++++++++ modules/xnet.php | 8 ++++---- templates/platal/password.tpl | 4 ++-- templates/xnet/account.mail.tpl | 2 +- templates/xnet/login.tpl | 4 ++-- templates/xnet/recovery.tpl | 2 +- templates/xnet/register.success.tpl | 2 +- 9 files changed, 25 insertions(+), 15 deletions(-) diff --git a/bin/cron/cron_xnet_accounts.php b/bin/cron/cron_xnet_accounts.php index 96543ff..de935e0 100755 --- a/bin/cron/cron_xnet_accounts.php +++ b/bin/cron/cron_xnet_accounts.php @@ -37,7 +37,7 @@ $i = 0; foreach ($users as $user) { $mailer->setTo($user['email']); $mailer->assign('hash', $user['hash']); - $mailer->assign('hruid', $user['hruid']); + $mailer->assign('email', $user['email']); $mailer->assign('group', $user['group_name']); $mailer->assign('sender_name', $user['sender_name']); $mailer->send(); diff --git a/classes/xnetsession.php b/classes/xnetsession.php index 765ad5e..27ed4d8 100644 --- a/classes/xnetsession.php +++ b/classes/xnetsession.php @@ -35,11 +35,12 @@ class XnetSession extends XorgSession } if (!S::logged() && Post::has('auth_type') && Post::v('auth_type') == 'xnet' && !Post::has('wait')) { + $email = Post::v('username'); $type = XDB::fetchOneCell('SELECT type FROM accounts - WHERE hruid = {?}', - Post::v('username')); - if (!is_null($type) && $type != 'xnet') { + WHERE email = {?}', + $email); + if ((!is_null($type) && $type != 'xnet') || !User::isForeignEmailAddress($email)) { Platal::page()->trigErrorRedirect('Ce formulaire d\'authentification est réservé aux extérieurs à la communauté polytechnicienne.', ''); } diff --git a/classes/xorgsession.php b/classes/xorgsession.php index 400f809..815ad81 100644 --- a/classes/xorgsession.php +++ b/classes/xorgsession.php @@ -151,6 +151,15 @@ class XorgSession extends PlSession } else if (Post::s('domain') == 'hruid') { $login = $uname; $loginType = 'hruid'; + } else if ((Post::s('domain') == 'email')) { + $login = XDB::fetchOneCell('SELECT SQL_CALC_FOUND_ROWS uid + FROM accounts + WHERE email = {?}', + $uname); + if (!(XDB::fetchOneCell('SELECT FOUND_ROWS()') == 1)) { + $login =null; + } + $loginType = 'uid'; } else { $login = $uname; $loginType = is_numeric($uname) ? 'uid' : 'alias'; diff --git a/modules/xnet.php b/modules/xnet.php index bd95e38..803cfc8 100644 --- a/modules/xnet.php +++ b/modules/xnet.php @@ -269,7 +269,7 @@ class XnetModule extends PLModule Platal::session()->startAvailableAuth(); $page->changeTpl('xnet/register.success.tpl'); - $page->assign('hruid', $res['hruid']); + $page->assign('email', $res['email']); } else { $page->changeTpl('platal/password.tpl'); $page->assign('xnet', true); @@ -336,7 +336,7 @@ Email envoyé à " . Post::t('login')); $page->trigErrorRedirect("Cette adresse n'existe pas ou n'existe plus sur le serveur.", ''); } - $hruid = XDB::fetchOneCell('SELECT hruid + $email = XDB::fetchOneCell('SELECT email FROM accounts WHERE uid = {?}', $uid); @@ -359,11 +359,11 @@ Email envoyé à " . Post::t('login')); Platal::session()->startAvailableAuth(); $page->changeTpl('xnet/register.success.tpl'); - $page->assign('hruid', $hruid); + $page->assign('email', $email); } else { $page->changeTpl('platal/password.tpl'); $page->assign('xnet_reset', true); - $page->assign('hruid', $hruid); + $page->assign('email', $email); $page->assign('do_auth', 1); } } diff --git a/templates/platal/password.tpl b/templates/platal/password.tpl index 5fb0c51..db20550 100644 --- a/templates/platal/password.tpl +++ b/templates/platal/password.tpl @@ -67,9 +67,9 @@ - + - + strictement personnelle'} colspan="2"> diff --git a/templates/xnet/account.mail.tpl b/templates/xnet/account.mail.tpl index 714a250..2cb632e 100644 --- a/templates/xnet/account.mail.tpl +++ b/templates/xnet/account.mail.tpl @@ -32,7 +32,7 @@ Bonjour, Après activation, vos paramètres de connexion seront : -identifiant : {$hruid} +identifiant : {$email} mot de passe : celui que vous choisirez Vous pouvez, dès à présent et pendant une période d'un mois, activer votre compte en cliquant sur le lien suivant : diff --git a/templates/xnet/login.tpl b/templates/xnet/login.tpl index 396f1ab..9356cb3 100644 --- a/templates/xnet/login.tpl +++ b/templates/xnet/login.tpl @@ -25,10 +25,10 @@
- + diff --git a/templates/xnet/recovery.tpl b/templates/xnet/recovery.tpl index fd337c9..de912f1 100644 --- a/templates/xnet/recovery.tpl +++ b/templates/xnet/recovery.tpl @@ -59,7 +59,7 @@ Si vous n'accéder pas à cet email dans les 6 heures, sollicitez un nouveau cer
Identifiant :Identifiant (adresse email) : - +
- Identifiant : + Identifiant (adresse email) : diff --git a/templates/xnet/register.success.tpl b/templates/xnet/register.success.tpl index f545dbf..b5ce382 100644 --- a/templates/xnet/register.success.tpl +++ b/templates/xnet/register.success.tpl @@ -30,7 +30,7 @@ profiter dès à présent des multiples fonctionnalités de Polytechnique.net.

- Pour rappel, votre identifiant est : {$hruid} + Pour rappel, votre identifiant est : {$email}

{* vim:set et sw=2 sts=2 sws=2 enc=utf-8: *} -- 2.1.4