Expire cookies properly in AuthenticationDefault::clearCookies
[bugdar.git] / includes / auth / auth_default.php
1 <?php
2 /*=====================================================================*\
3 || ###################################################################
4 || # Bugdar
5 || # Copyright ©2002-2007 Blue Static
6 || #
7 || # This program is free software; you can redistribute it and/or modify
8 || # it under the terms of the GNU General Public License as published by
9 || # the Free Software Foundation; version 2 of the License.
10 || #
11 || # This program is distributed in the hope that it will be useful, but
12 || # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13 || # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
14 || # more details.
15 || #
16 || # You should have received a copy of the GNU General Public License along
17 || # with this program; if not, write to the Free Software Foundation, Inc.,
18 || # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
19 || ###################################################################
20 \*=====================================================================*/
21
22 require_once('./includes/auth/auth.php');
23
24 /**
25 * Authentication Default
26 *
27 * Default authentication scheme to allow Bugdar to manage its own users.
28 *
29 * @author Blue Static
30 * @copyright Copyright (c)2002 - 2007, Blue Static
31 * @version $Revision$
32 * @package Bugdar
33 *
34 */
35 class AuthenticationDefault extends Authentication
36 {
37 // ###################################################################
38 function _setupDatabase()
39 {
40 $this->authDb = $this->db;
41 }
42
43 // ###################################################################
44 function _fetchCookieUniqueId()
45 {
46 return BSApp::$input->inputClean(COOKIE_PREFIX . 'userid', TYPE_UINT);
47 }
48
49 // ###################################################################
50 function _fetchCookiePassword()
51 {
52 return BSApp::$input->in[COOKIE_PREFIX . 'authkey'];
53 }
54
55 // ###################################################################
56 function _fetchUserUsingCookies()
57 {
58 return $this->db->queryFirst("SELECT * FROM " . TABLE_PREFIX . "user WHERE userid = " . $this->_fetchCookieUniqueId());
59 }
60
61 // ###################################################################
62 function _verifyCookieData()
63 {
64 return ($this->authUser['authkey'] == $this->_fetchCookiePassword());
65 }
66
67 // ###################################################################
68 function _setCookies($sticky = false)
69 {
70 BSFunctions::cookie(COOKIE_PREFIX . 'userid', $this->authUser['userid'], $sticky);
71 BSFunctions::cookie(COOKIE_PREFIX . 'authkey', $this->authUser['authkey'], $sticky);
72 }
73
74 // ###################################################################
75 function clearCookies()
76 {
77 BSFunctions::cookie(COOKIE_PREFIX . 'userid', false);
78 BSFunctions::cookie(COOKIE_PREFIX . 'authkey', false);
79 }
80
81 // ###################################################################
82 function _fetchBugdarUserFromAuthUser()
83 {
84 return $this->authUser;
85 }
86
87 // ###################################################################
88 function _fetchUserWithIdentifier($email)
89 {
90 return $this->authDb->queryFirst("SELECT * FROM " . TABLE_PREFIX . "user WHERE email = '" . $this->authDb->escapeString($email) . "'");
91 }
92
93 // ###################################################################
94 function _verifyLoginUser($password)
95 {
96 return ($this->authUser['password'] == md5(md5($password) . md5($this->authUser['salt'])));
97 }
98
99 // ###################################################################
100 function _syncBugdarUser() {}
101 }
102
103 /*=====================================================================*\
104 || ###################################################################
105 || # $HeadURL$
106 || # $Id$
107 || ###################################################################
108 \*=====================================================================*/
109 ?>