|
@@ -206,34 +206,26 @@ class Authcompany
|
|
|
* @param bool $ignoreoldpassword 忽略旧密码
|
|
|
* @return boolean
|
|
|
*/
|
|
|
- public function changepwd($newpassword, $oldpassword = '', $ignoreoldpassword = false)
|
|
|
+ public function resetpwd($newpassword)
|
|
|
{
|
|
|
if (!$this->_logined) {
|
|
|
$this->setError('You are not logged in');
|
|
|
return false;
|
|
|
}
|
|
|
- //判断旧密码是否正确
|
|
|
- if ($this->_user->password == $this->getEncryptPassword($oldpassword, $this->_user->salt) || $ignoreoldpassword) {
|
|
|
- Db::startTrans();
|
|
|
- try {
|
|
|
- $salt = Random::alnum();
|
|
|
- $newpassword = $this->getEncryptPassword($newpassword, $salt);
|
|
|
- $this->_user->save(['loginfailure' => 0, 'password' => $newpassword, 'salt' => $salt]);
|
|
|
|
|
|
- Tokencompany::delete($this->_token);
|
|
|
- //修改密码成功的事件
|
|
|
- Hook::listen("company_changepwd_successed", $this->_user);
|
|
|
- Db::commit();
|
|
|
- } catch (Exception $e) {
|
|
|
- Db::rollback();
|
|
|
- $this->setError($e->getMessage());
|
|
|
- return false;
|
|
|
- }
|
|
|
- return true;
|
|
|
- } else {
|
|
|
- $this->setError('Password is incorrect');
|
|
|
- return false;
|
|
|
- }
|
|
|
+ Db::startTrans();
|
|
|
+
|
|
|
+ $salt = Random::alnum();
|
|
|
+ $newpassword = $this->getEncryptPassword($newpassword, $salt);
|
|
|
+ unset($this->_user['company']);
|
|
|
+ $this->_user->save(['password' => $newpassword, 'salt' => $salt]);
|
|
|
+
|
|
|
+ Tokencompany::delete($this->_token);
|
|
|
+
|
|
|
+ Db::commit();
|
|
|
+
|
|
|
+ return true;
|
|
|
+
|
|
|
}
|
|
|
|
|
|
/**
|