From 73f2bb48667fc29db93551f9b1681fe5b1918bc7 Mon Sep 17 00:00:00 2001
From: =?utf8?q?St=C3=A9phane=20Jacob?=
Date: Sun, 20 Mar 2011 20:54:00 +0100
Subject: [PATCH] Seperates password edition from xnet profile edition, removes
account deletion.
MIME-Version: 1.0
Content-Type: text/plain; charset=utf8
Content-Transfer-Encoding: 8bit
Signed-off-by: Stéphane Jacob
---
classes/xnetpage.php | 1 +
modules/platal.php | 2 ++
modules/xnet.php | 37 +++++++++++++++++++++++--------------
templates/platal/password.tpl | 11 ++++++-----
templates/xnet/edit.tpl | 22 ----------------------
5 files changed, 32 insertions(+), 41 deletions(-)
diff --git a/classes/xnetpage.php b/classes/xnetpage.php
index 610f26c..e2075b0 100644
--- a/classes/xnetpage.php
+++ b/classes/xnetpage.php
@@ -83,6 +83,7 @@ class XnetPage extends PlPage
$sub['documentation'] = 'Xnet';
if (S::user()->type == 'xnet') {
$sub['mon compte'] = 'edit';
+ $sub['mon mot de passe'] = 'password';
}
$sub['signaler un bug'] = array('href' => 'send_bug/'.$_SERVER['REQUEST_URI'], 'class' => 'popup_840x600');
$menu["no_title"] = $sub;
diff --git a/modules/platal.php b/modules/platal.php
index 29821a6..d3d3cd4 100644
--- a/modules/platal.php
+++ b/modules/platal.php
@@ -229,6 +229,7 @@ class PlatalModule extends PLModule
$page->changeTpl('platal/password.tpl');
$page->setTitle('Mon mot de passe');
+ $page->assign('do_auth', false);
}
function handler_smtppass($page)
@@ -396,6 +397,7 @@ Adresse de secours : " . Post::v('email') : ""));
$uid);
$page->changeTpl('platal/password.tpl');
$page->assign('hruid', $hruid);
+ $page->assign('do_auth', true);
}
}
diff --git a/modules/xnet.php b/modules/xnet.php
index 45bc80f..6e54d38 100644
--- a/modules/xnet.php
+++ b/modules/xnet.php
@@ -36,6 +36,7 @@ class XnetModule extends PLModule
'login/ext' => $this->make_hook('login_ext', AUTH_PUBLIC),
'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(),
);
@@ -271,6 +272,7 @@ class XnetModule extends PLModule
$page->changeTpl('platal/password.tpl');
$page->assign('xnet', true);
$page->assign('hruid', $res['hruid']);
+ $page->assign('do_auth', true);
}
}
@@ -290,13 +292,6 @@ class XnetModule extends PLModule
if (Post::has('change')) {
S::assert_xsrf_token();
- if ($user->groupCount() == 0 && Post::t('delete') == 'OUI') {
- XDB::execute('DELETE FROM accounts
- WHERE uid = {?}',
- $user->id());
- pl_redirect('index');
- }
-
// Convert user status to X
if (!Post::blank('login_X')) {
$forlife = $this->changeLogin($page, $user, Post::t('login_X'));
@@ -312,13 +307,6 @@ class XnetModule extends PLModule
WHERE uid = {?}',
Post::t('full_name'), Post::t('directory_name'), Post::t('display_name'),
(Post::t('sex') == 'male') ? 'male' : 'female', Post::t('email'), $user->id());
- // If user is of type xnet and new password is given.
- if (!Post::blank('pwhash')) {
- XDB::query('UPDATE accounts
- SET password = {?}
- WHERE uid = {?}',
- Post::t('pwhash'), $user->id());
- }
if (XDB::affectedRows()) {
$page->trigSuccess('Données mises à jour.');
}
@@ -327,6 +315,27 @@ class XnetModule extends PLModule
$page->addJsLink('password.js');
$page->assign('user', $user);
}
+
+ function handler_password ($page)
+ {
+ 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);
+ }
}
// vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8:
diff --git a/templates/platal/password.tpl b/templates/platal/password.tpl
index 94dd077..5fb0c51 100644
--- a/templates/platal/password.tpl
+++ b/templates/platal/password.tpl
@@ -31,8 +31,9 @@
Attention au type de clavier que tu utilises (qwerty ?) et aux majuscules/minuscules.
- Pour une sécurité optimale, le mot de passe circule de manière chiffrée (https) et est
- stocké chiffré irréversiblement sur nos serveurs.
+ Pour une sécurité optimale, le mot de passe
+ {if !t($xnet)}{if !t($xnet_reset)} circule de manière chiffrée (https) et{/if}{/if}
+ est stocké chiffré irréversiblement sur nos serveurs.