Subversion Repositories oidplus

Rev

Rev 454 | Rev 460 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 454 Rev 459
Line 48... Line 48...
48
                }
48
                }
49
                return $out;
49
                return $out;
50
        }
50
        }
51
 
51
 
52
        public function change_password($new_password) {
52
        public function change_password($new_password) {
53
                list($s_salt, $calc_authkey) = OIDplus::authUtils()->raGeneratePassword($new_password);
53
                $authInfo = OIDplus::authUtils()->raGeneratePassword($new_password);
-
 
54
                $s_salt = $authInfo->getSalt();
-
 
55
                $calc_authkey = $authInfo->getAuthKey();
54
                OIDplus::db()->query("update ###ra set salt=?, authkey=? where email = ?", array($s_salt, $calc_authkey, $this->email));
56
                OIDplus::db()->query("update ###ra set salt=?, authkey=? where email = ?", array($s_salt, $calc_authkey, $this->email));
55
        }
57
        }
56
 
58
 
57
        public function change_email($new_email) {
59
        public function change_email($new_email) {
58
                OIDplus::db()->query("update ###ra set email = ? where email = ?", array($new_email, $this->email));
60
                OIDplus::db()->query("update ###ra set email = ? where email = ?", array($new_email, $this->email));
Line 62... Line 64...
62
                if (is_null($new_password)) {
64
                if (is_null($new_password)) {
63
                        // Invalid password (used for LDAP/OAuth)
65
                        // Invalid password (used for LDAP/OAuth)
64
                        $s_salt = '';
66
                        $s_salt = '';
65
                        $calc_authkey = '';
67
                        $calc_authkey = '';
66
                } else {
68
                } else {
67
                        list($s_salt, $calc_authkey) = OIDplus::authUtils()->raGeneratePassword($new_password);
69
                        $authInfo = OIDplus::authUtils()->raGeneratePassword($new_password);
-
 
70
                        $s_salt = $authInfo->getSalt();
-
 
71
                        $calc_authkey = $authInfo->getAuthKey();
68
                }
72
                }
69
 
73
 
70
                OIDplus::db()->query("insert into ###ra (salt, authkey, email, registered, ra_name, personal_name, organization, office, street, zip_town, country, phone, mobile, fax) values (?, ?, ?, ".OIDplus::db()->sqlDate().", ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", array($s_salt, $calc_authkey, $this->email, "", "", "", "", "", "", "", "", "", ""));
74
                OIDplus::db()->query("insert into ###ra (salt, authkey, email, registered, ra_name, personal_name, organization, office, street, zip_town, country, phone, mobile, fax) values (?, ?, ?, ".OIDplus::db()->sqlDate().", ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", array($s_salt, $calc_authkey, $this->email, "", "", "", "", "", "", "", "", "", ""));
71
        }
75
        }
72
 
76
 
73
        public function getAuthInfo() {
77
        public function getAuthInfo(): OIDplusRAAuthInfo {
74
                $ra_res = OIDplus::db()->query("select authkey, salt from ###ra where email = ?", array($this->email));
78
                $ra_res = OIDplus::db()->query("select authkey, salt from ###ra where email = ?", array($this->email));
75
                if ($ra_res->num_rows() == 0) return false; // User not found
79
                if ($ra_res->num_rows() == 0) return false; // User not found
76
                $ra_row = $ra_res->fetch_array();
80
                $ra_row = $ra_res->fetch_array();
77
 
81
 
78
                return array($ra_row['salt'], $ra_row['authkey']);
82
                return new OIDplusRAAuthInfo($this->email, $ra_row['salt'], $ra_row['authkey']);
79
        }
83
        }
80
 
84
 
81
        public function checkPassword($password) {
85
        public function checkPassword($password) {
82
                return OIDplus::authUtils()->raCheckPassword($this->email, $password);
86
                return OIDplus::authUtils()->raCheckPassword($this->email, $password);
83
        }
87
        }
Line 89... Line 93...
89
        public function setRaName($ra_name) {
93
        public function setRaName($ra_name) {
90
                OIDplus::db()->query("update ###ra set ra_name = ? where email = ?", array($ra_name, $this->email));
94
                OIDplus::db()->query("update ###ra set ra_name = ? where email = ?", array($ra_name, $this->email));
91
        }
95
        }
92
 
96
 
93
        public function isPasswordLess() {
97
        public function isPasswordLess() {
94
                list($salt, $authkey) = $this->getAuthInfo();
98
                return $this->getAuthInfo()->isPasswordLess();
95
                return $authkey === '';
-
 
96
        }
99
        }
97
}
100
}