|
@@ -133,6 +133,7 @@ class Auth
|
|
*/
|
|
*/
|
|
public function register($username, $password, $email = '', $mobile = '', $extend = [])
|
|
public function register($username, $password, $email = '', $mobile = '', $extend = [])
|
|
{
|
|
{
|
|
|
|
+ $request = Request::instance();
|
|
// 检测用户名、昵称、邮箱、手机号是否存在
|
|
// 检测用户名、昵称、邮箱、手机号是否存在
|
|
if (User::getByUsername($username)) {
|
|
if (User::getByUsername($username)) {
|
|
$this->setError('Username already exist');
|
|
$this->setError('Username already exist');
|
|
@@ -178,18 +179,20 @@ class Auth
|
|
//设置Token
|
|
//设置Token
|
|
$this->_token = Random::uuid();
|
|
$this->_token = Random::uuid();
|
|
Token::set($this->_token, $user->id, $this->keeptime);
|
|
Token::set($this->_token, $user->id, $this->keeptime);
|
|
|
|
+ $user->token = $this->_token;
|
|
|
|
+ $user->save();
|
|
|
|
|
|
//设置登录状态
|
|
//设置登录状态
|
|
// $this->_logined = true;
|
|
// $this->_logined = true;
|
|
|
|
|
|
//注册成功的事件
|
|
//注册成功的事件
|
|
- Hook::listen("user_register_successed", $this->_user, $data);
|
|
|
|
|
|
+// Hook::listen("user_register_successed", $this->_user, $data);
|
|
|
|
|
|
//TODO 发送邮件内容
|
|
//TODO 发送邮件内容
|
|
$email = new Email;
|
|
$email = new Email;
|
|
$email->to($username)
|
|
$email->to($username)
|
|
->subject(config('site.mail_title')) // 标题
|
|
->subject(config('site.mail_title')) // 标题
|
|
- ->message(config('site.mail_content') . 'Please click on the link to login' . '<a href="'. config('site.cdnurl') .'">' . config('site.cdnurl') . '</a>') // 内容 链接地址写死
|
|
|
|
|
|
+ ->message(config('site.mail_content') . 'Please click on the link to login ' . '<a href="'. $request->domain() . '/index/user/login?token=' . $this->_token . '-' . $user->id .'">Address</a>') // 内容 链接地址写死
|
|
->send();
|
|
->send();
|
|
|
|
|
|
Db::commit();
|
|
Db::commit();
|
|
@@ -226,6 +229,11 @@ class Auth
|
|
return false;
|
|
return false;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ if ($user->is_register != 'normal') {
|
|
|
|
+ $this->setError('Please go to the email and click on the corresponding address to register');
|
|
|
|
+ return false;
|
|
|
|
+ }
|
|
|
|
+
|
|
//直接登录会员
|
|
//直接登录会员
|
|
return $this->direct($user->id);
|
|
return $this->direct($user->id);
|
|
}
|
|
}
|
|
@@ -319,15 +327,15 @@ class Auth
|
|
$this->_user = $user;
|
|
$this->_user = $user;
|
|
|
|
|
|
$this->_token = Random::uuid();
|
|
$this->_token = Random::uuid();
|
|
- Token::set($this->_token, $user->id, $this->keeptime);
|
|
|
|
-
|
|
|
|
$user->token = $this->_token;
|
|
$user->token = $this->_token;
|
|
$user->save();
|
|
$user->save();
|
|
|
|
+ Token::set($this->_token, $user->id, $this->keeptime);
|
|
|
|
|
|
$this->_logined = true;
|
|
$this->_logined = true;
|
|
|
|
|
|
//登录成功的事件
|
|
//登录成功的事件
|
|
Hook::listen("user_login_successed", $this->_user);
|
|
Hook::listen("user_login_successed", $this->_user);
|
|
|
|
+
|
|
Db::commit();
|
|
Db::commit();
|
|
} catch (Exception $e) {
|
|
} catch (Exception $e) {
|
|
Db::rollback();
|
|
Db::rollback();
|