summaryrefslogtreecommitdiff
path: root/src/lib/Login.class.php
diff options
context:
space:
mode:
authorLuke Shumaker <LukeShu@sbcglobal.net>2011-09-04 21:13:47 -0400
committerLuke Shumaker <LukeShu@sbcglobal.net>2011-09-04 21:13:47 -0400
commitad4a7ff9159c2c64cea98d7189f46fa7d6174fc2 (patch)
tree508f971f1dbc6c6f01207426c675542b55e0333e /src/lib/Login.class.php
parentf3b3ea69fb46e45bf3598aa7a6bcf62aa80e4703 (diff)
Screw it, I'm tired of trying to break this into individual commits
Diffstat (limited to 'src/lib/Login.class.php')
-rw-r--r--src/lib/Login.class.php31
1 files changed, 31 insertions, 0 deletions
diff --git a/src/lib/Login.class.php b/src/lib/Login.class.php
new file mode 100644
index 0000000..26d11dd
--- /dev/null
+++ b/src/lib/Login.class.php
@@ -0,0 +1,31 @@
+<?php
+
+class Login {
+ public static function login($username, $password) {
+ global $mm;
+ $uid = $mm->database()->getUID($username);
+ if ($uid===false) {
+ // user does not exist
+ return 2;
+ }
+ $hash = $mm->database()->getPasswordHash($uid);
+ if ($mm->hasher()->CheckPassword($password, $hash)) {
+ // success
+ $_SESSION['uid'] = $uid;
+ return 0;
+ } else {
+ // wrong password
+ return 1;
+ }
+ }
+ public static function isLoggedIn() {
+ if ( isset($_SESSION['uid']) && ($_SESSION['uid']!='') ) {
+ return $_SESSION['uid'];
+ } else {
+ return false;
+ }
+ }
+ public static function logout() {
+ $_SESSION['uid'] = '';
+ }
+}