X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;f=modules%2Fxnet.php;h=ae6edc4aee078faff0560e0b77c7259ca980251c;hb=d4cb8f1fea2a6f2cc2bc0411f94c12195d2c99b2;hp=6e54d385bda040e2657b94fdce9236c6be4f5d69;hpb=73f2bb48667fc29db93551f9b1681fe5b1918bc7;p=platal.git diff --git a/modules/xnet.php b/modules/xnet.php index 6e54d38..ae6edc4 100644 --- a/modules/xnet.php +++ b/modules/xnet.php @@ -24,21 +24,19 @@ class XnetModule extends PLModule function handlers() { return array( - 'index' => $this->make_hook('index', AUTH_PUBLIC), - 'exit' => $this->make_hook('exit', AUTH_PUBLIC), - - 'admin' => $this->make_hook('admin', AUTH_MDP, 'admin'), - 'groups' => $this->make_hook('groups', AUTH_PUBLIC), - 'groupes.php' => $this->make_hook('groups2', AUTH_PUBLIC), - 'plan' => $this->make_hook('plan', AUTH_PUBLIC), - 'photo' => $this->make_hook('photo', AUTH_MDP), - 'autologin' => $this->make_hook('autologin', AUTH_MDP), - 'login/ext' => $this->make_hook('login_ext', AUTH_PUBLIC), + 'index' => $this->make_hook('index', AUTH_PUBLIC), + 'exit' => $this->make_hook('exit', AUTH_PUBLIC), + + 'admin' => $this->make_hook('admin', AUTH_PASSWD, 'admin'), + 'groups' => $this->make_hook('groups', AUTH_PUBLIC), + 'groupes.php' => $this->make_hook('groups2', AUTH_PUBLIC), + 'plan' => $this->make_hook('plan', AUTH_PUBLIC), + // Should be removed in a future release as links will have expired anyway. 'register/ext' => $this->make_hook('register_ext', AUTH_PUBLIC), - 'edit' => $this->make_hook('edit', AUTH_MDP, 'user'), - 'password' => $this->make_hook('password', AUTH_MDP, 'user'), - - 'Xnet' => $this->make_wiki_hook(), + 'photo' => $this->make_hook('photo', AUTH_PASSWD, 'groups'), + 'autologin' => $this->make_hook('autologin', AUTH_PASSWD, 'groups'), + 'edit' => $this->make_hook('edit', AUTH_PASSWD, 'groups'), + 'Xnet' => $this->make_wiki_hook(), ); } @@ -228,54 +226,6 @@ class XnetModule extends PLModule exit; } - function handler_login_ext($page) - { - if (!S::logged()) { - $page->changeTpl('xnet/login.tpl'); - } else { - pl_redirect(''); - } - } - - function handler_register_ext($page, $hash = null) - { - XDB::execute('DELETE FROM register_pending_xnet - WHERE DATE_SUB(NOW(), INTERVAL 1 MONTH) > date'); - $res = XDB::fetchOneAssoc('SELECT uid, hruid - FROM register_pending_xnet - WHERE hash = {?}', - $hash); - - if (is_null($hash) || is_null($res)) { - $page->trigErrorRedirect('Cette adresse n\'existe pas ou n\'existe plus sur le serveur.', ''); - } - - if (Post::has('pwhash') && Post::t('pwhash')) { - XDB::query('UPDATE accounts - SET password = {?}, state = \'active\' - WHERE uid = {?} AND state = \'pending\' AND type = \'xnet\'', - Post::t('pwhash'), $res['uid']); - XDB::query('DELETE FROM register_pending_xnet - WHERE uid = {?}', - $res['uid']); - - S::logger($res['uid'])->log('passwd', ''); - - // Try to start a session (so the user don't have to log in); we will use - // the password available in Post:: to authenticate the user. - Post::kill('wait'); - Platal::session()->startAvailableAuth(); - - $page->changeTpl('xnet/register.success.tpl'); - $page->assign('hruid', $res['hruid']); - } else { - $page->changeTpl('platal/password.tpl'); - $page->assign('xnet', true); - $page->assign('hruid', $res['hruid']); - $page->assign('do_auth', true); - } - } - function handler_edit($page) { global $globals; @@ -301,13 +251,24 @@ class XnetModule extends PLModule } // Update user info + $full_name = Post::t('firstname') . ' ' . Post::t('lastname'); + $directory_name = mb_strtoupper(Post::t('lastname')) . ' ' . Post::t('firstname'); XDB::query('UPDATE accounts SET full_name = {?}, directory_name = {?}, display_name = {?}, - sex = {?}, email = {?} + firstname = {?}, lastname = {?}, sex = {?}, email = {?} WHERE uid = {?}', - Post::t('full_name'), Post::t('directory_name'), Post::t('display_name'), + $full_name, $directory_name, Post::t('display_name'), + Post::t('firstname'), Post::t('lastname'), (Post::t('sex') == 'male') ? 'male' : 'female', Post::t('email'), $user->id()); if (XDB::affectedRows()) { + require_once 'emails.inc.php'; + if (require_email_update($user, Post::t('email'))) { + $listClient = new MMList(S::user()); + $listClient->change_user_email($user->forlifeEmail(), Post::t('email')); + update_alias_user($user->forlifeEmail(), Post::t('email')); + } + $user = User::getWithUID($user->id()); + S::set('user', $user); $page->trigSuccess('Données mises à jour.'); } } @@ -316,25 +277,9 @@ class XnetModule extends PLModule $page->assign('user', $user); } - function handler_password ($page) + function handler_register_ext($page, $hash = null) { - if (Post::has('pwhash') && Post::t('pwhash')) { - S::assert_xsrf_token(); - - S::set('password', $password = Post::t('pwhash')); - XDB::execute('UPDATE accounts - SET password = {?} - WHERE uid={?}', $password, - S::i('uid')); - S::logger()->log('passwd'); - Platal::session()->setAccessCookie(true); - $page->changeTpl('platal/password.success.tpl'); - $page->run(); - } - - $page->changeTpl('platal/password.tpl'); - $page->assign('xnet_reset', true); - $page->assign('do_auth', false); + http_redirect(Platal::globals()->xnet->xorg_baseurl . 'register/ext/' . $hash); } }