summaryrefslogtreecommitdiffstats
path: root/inc/user.inc.php
diff options
context:
space:
mode:
authorSimon Rettberg2016-09-08 18:43:47 +0200
committerSimon Rettberg2016-09-08 18:43:47 +0200
commitad4f4e405aed82cd0f87e51874043a2d054a1c01 (patch)
tree284362f85a9c31859e8e0a043e53325482812bae /inc/user.inc.php
parent[roomplanner] ajax saving: Better error messages on .fail() (diff)
downloadslx-admin-ad4f4e405aed82cd0f87e51874043a2d054a1c01.tar.gz
slx-admin-ad4f4e405aed82cd0f87e51874043a2d054a1c01.tar.xz
slx-admin-ad4f4e405aed82cd0f87e51874043a2d054a1c01.zip
[session] Add simple "change password" GUI
Diffstat (limited to 'inc/user.inc.php')
-rw-r--r--inc/user.inc.php17
1 files changed, 17 insertions, 0 deletions
diff --git a/inc/user.inc.php b/inc/user.inc.php
index dc603dac..f7688b00 100644
--- a/inc/user.inc.php
+++ b/inc/user.inc.php
@@ -49,6 +49,23 @@ class User
return false;
}
+ public static function testPassword($userid, $password)
+ {
+ $ret = Database::queryFirst('SELECT passwd FROM user WHERE userid = :userid LIMIT 1', compact('userid'));
+ if ($ret === false)
+ return false;
+ return Crypto::verify($password, $ret['passwd']);
+ }
+
+ public static function updatePassword($password)
+ {
+ if (!self::isLoggedIn())
+ return;
+ $passwd = Crypto::hash6($password);
+ $userid = self::getId();
+ return Database::exec('UPDATE user SET passwd = :passwd WHERE userid = :userid LIMIT 1', compact('userid', 'passwd')) > 0;
+ }
+
public static function login($user, $pass)
{
$ret = Database::queryFirst('SELECT userid, passwd FROM user WHERE login = :user LIMIT 1', array(':user' => $user));