|
@@ -216,11 +216,17 @@ class Auth
|
|
|
* @param array $extend 扩展参数
|
|
|
* @return boolean
|
|
|
*/
|
|
|
- public function register($username, $password, $email = '', $mobile = '', $extend = [])
|
|
|
+ public function register($username, $password = '', $email = '', $mobile = '', $extend = [])
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
+ if ($email && User::getByEmail($email)) {
|
|
|
+ $this->setError('Email already exist');
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
if ($mobile && User::getByMobile($mobile)) {
|
|
|
$this->setError('Mobile already exist');
|
|
|
return false;
|
|
@@ -232,14 +238,21 @@ class Auth
|
|
|
$introcode = User::column("introcode");
|
|
|
|
|
|
$data = [
|
|
|
+ 'email' => $email,
|
|
|
'mobile' => $mobile,
|
|
|
- /*'level' => 1,
|
|
|
- 'score' => 0,*/
|
|
|
+
|
|
|
'avatar' => $extend['gender'] == 1 ? config('avatar_boy') : config('avatar_girl'),
|
|
|
'introcode' => $this->getUinqueNo(6, $introcode),
|
|
|
+ 'nickname' => $this->get_rand_nick_name(),
|
|
|
+
|
|
|
];
|
|
|
+
|
|
|
+ if($password){
|
|
|
+ $data['salt'] = Random::alnum();
|
|
|
+ $data['password'] = $this->getEncryptPassword($password, $data['salt']);
|
|
|
+ }
|
|
|
+
|
|
|
$params = array_merge($data, [
|
|
|
- 'nickname' => $this->get_rand_nick_name(),
|
|
|
'jointime' => $time,
|
|
|
'joinip' => $ip,
|
|
|
'logintime' => $time,
|
|
@@ -500,7 +513,7 @@ class Auth
|
|
|
public function login($account, $password)
|
|
|
{
|
|
|
//$field = Validate::is($account, 'email') ? 'email' : (Validate::regex($account, '/^1\d{10}$/') ? 'mobile' : 'username');
|
|
|
- $field = 'mobile';
|
|
|
+ $field = 'email';
|
|
|
$user = User::get([$field => $account]);
|
|
|
if (!$user) {
|
|
|
$this->setError('Account is incorrect');
|
|
@@ -521,9 +534,7 @@ class Auth
|
|
|
}
|
|
|
|
|
|
//直接登录会员
|
|
|
- $this->direct($user->id);
|
|
|
-
|
|
|
- return true;
|
|
|
+ return $this->direct($user->id);
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -679,6 +690,15 @@ class Auth
|
|
|
/**
|
|
|
* 获取会员基本信息
|
|
|
*/
|
|
|
+ public function getUserinfo_simple(){
|
|
|
+ $user_info = Token::get($this->_token);
|
|
|
+ $user_info['id'] = $user_info['user_id'];
|
|
|
+ return $user_info;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取会员基本信息
|
|
|
+ */
|
|
|
public function getUserinfo()
|
|
|
{
|
|
|
$data = $this->_user->toArray();
|