From ad4a7ff9159c2c64cea98d7189f46fa7d6174fc2 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Sun, 4 Sep 2011 21:13:47 -0400 Subject: Screw it, I'm tired of trying to break this into individual commits --- src/lib/Login.class.php | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 src/lib/Login.class.php (limited to 'src/lib/Login.class.php') 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 @@ +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'] = ''; + } +} -- cgit v1.2.3-2-g168b