diff options
author | Luke Shumaker <LukeShu@sbcglobal.net> | 2011-09-04 21:13:47 -0400 |
---|---|---|
committer | Luke Shumaker <LukeShu@sbcglobal.net> | 2011-09-04 21:13:47 -0400 |
commit | ad4a7ff9159c2c64cea98d7189f46fa7d6174fc2 (patch) | |
tree | 508f971f1dbc6c6f01207426c675542b55e0333e /src/lib/Login.class.php | |
parent | f3b3ea69fb46e45bf3598aa7a6bcf62aa80e4703 (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.php | 31 |
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'] = ''; + } +} |