|
@@ -17,7 +17,7 @@ use miniprogram\wxBizDataCrypt;
|
|
*/
|
|
*/
|
|
class User extends Api
|
|
class User extends Api
|
|
{
|
|
{
|
|
- protected $noNeedLogin = ['login', 'mobilelogin', 'register', 'resetpwd', 'changeemail', 'changemobile', 'third', 'getUserOpenid','wxMiniProgramLogin'];
|
|
|
|
|
|
+ protected $noNeedLogin = ['emaillogin', 'mobilelogin', 'register', 'resetpwd', 'changeemail', 'changemobile'];
|
|
protected $noNeedRight = '*';
|
|
protected $noNeedRight = '*';
|
|
|
|
|
|
public function _initialize()
|
|
public function _initialize()
|
|
@@ -45,7 +45,7 @@ class User extends Api
|
|
* @param string $account 账号
|
|
* @param string $account 账号
|
|
* @param string $password 密码
|
|
* @param string $password 密码
|
|
*/
|
|
*/
|
|
- public function login()
|
|
|
|
|
|
+ public function emaillogin()
|
|
{
|
|
{
|
|
$account = input('account');
|
|
$account = input('account');
|
|
$password = input('password');
|
|
$password = input('password');
|
|
@@ -54,7 +54,7 @@ class User extends Api
|
|
}
|
|
}
|
|
$ret = $this->auth->login($account, $password);
|
|
$ret = $this->auth->login($account, $password);
|
|
if ($ret) {
|
|
if ($ret) {
|
|
- $data = ['userinfo' => $this->auth->getUserinfo()];
|
|
|
|
|
|
+ $data = $this->auth->getUserinfo();
|
|
$this->success(__('Logged in successful'), $data);
|
|
$this->success(__('Logged in successful'), $data);
|
|
} else {
|
|
} else {
|
|
$this->error($this->auth->getError());
|
|
$this->error($this->auth->getError());
|
|
@@ -70,14 +70,16 @@ class User extends Api
|
|
*/
|
|
*/
|
|
public function mobilelogin()
|
|
public function mobilelogin()
|
|
{
|
|
{
|
|
|
|
+ $countrycode = input('countrycode',86,'intval');
|
|
$mobile = input('mobile');
|
|
$mobile = input('mobile');
|
|
$captcha = input('captcha');
|
|
$captcha = input('captcha');
|
|
- if (!$mobile || !$captcha) {
|
|
|
|
|
|
+ if (!$countrycode || !$mobile || !$captcha) {
|
|
$this->error(__('Invalid parameters'));
|
|
$this->error(__('Invalid parameters'));
|
|
}
|
|
}
|
|
- if (!Validate::regex($mobile, "^1\d{10}$")) {
|
|
|
|
|
|
+ /*if (!Validate::regex($mobile, "^1\d{10}$")) {
|
|
$this->error(__('Mobile is incorrect'));
|
|
$this->error(__('Mobile is incorrect'));
|
|
- }
|
|
|
|
|
|
+ }*/
|
|
|
|
+ $mobile = $countrycode.$mobile;
|
|
if (!Sms::check($mobile, $captcha, 'mobilelogin')) {
|
|
if (!Sms::check($mobile, $captcha, 'mobilelogin')) {
|
|
$this->error(__('Captcha is incorrect'));
|
|
$this->error(__('Captcha is incorrect'));
|
|
}
|
|
}
|
|
@@ -89,7 +91,8 @@ class User extends Api
|
|
//如果已经有账号则直接登录
|
|
//如果已经有账号则直接登录
|
|
$ret = $this->auth->direct($user->id);
|
|
$ret = $this->auth->direct($user->id);
|
|
} else {
|
|
} else {
|
|
- $ret = $this->auth->register('', '', '', $mobile, []);
|
|
|
|
|
|
+ //$ret = $this->auth->register('', '', '', $mobile, []);
|
|
|
|
+ $this->error('Account is incorrect');
|
|
}
|
|
}
|
|
if ($ret) {
|
|
if ($ret) {
|
|
Sms::flush($mobile, 'mobilelogin');
|
|
Sms::flush($mobile, 'mobilelogin');
|
|
@@ -112,27 +115,52 @@ class User extends Api
|
|
*/
|
|
*/
|
|
public function register()
|
|
public function register()
|
|
{
|
|
{
|
|
- $username = input('username');
|
|
|
|
- $password = input('password');
|
|
|
|
- $email = input('email');
|
|
|
|
- $mobile = input('mobile');
|
|
|
|
- $code = input('code');
|
|
|
|
- if (!$username || !$password) {
|
|
|
|
|
|
+ $firstname = input('firstname');
|
|
|
|
+ $lastname = input('lastname');
|
|
|
|
+
|
|
|
|
+ $countrycode = input('countrycode',86,'intval');
|
|
|
|
+ $mobile = input('mobile');
|
|
|
|
+ $captcha = input('captcha');
|
|
|
|
+
|
|
|
|
+ $email = input('email');
|
|
|
|
+ $emailcaptcha = input('emailcaptcha');
|
|
|
|
+
|
|
|
|
+ if (!$firstname || !$lastname || !$mobile || !$captcha || !$email || !$emailcaptcha ) {
|
|
$this->error(__('Invalid parameters'));
|
|
$this->error(__('Invalid parameters'));
|
|
}
|
|
}
|
|
|
|
+
|
|
if ($email && !Validate::is($email, "email")) {
|
|
if ($email && !Validate::is($email, "email")) {
|
|
$this->error(__('Email is incorrect'));
|
|
$this->error(__('Email is incorrect'));
|
|
}
|
|
}
|
|
- if ($mobile && !Validate::regex($mobile, "^1\d{10}$")) {
|
|
|
|
|
|
+ /*if ($mobile && !Validate::regex($mobile, "^1\d{10}$")) {
|
|
$this->error(__('Mobile is incorrect'));
|
|
$this->error(__('Mobile is incorrect'));
|
|
|
|
+ }*/
|
|
|
|
+
|
|
|
|
+ $password = input('password');
|
|
|
|
+
|
|
|
|
+ $fullmobile = $countrycode.$mobile;
|
|
|
|
+ $ret = Sms::check($fullmobile, $captcha, 'register');
|
|
|
|
+ if (!$ret) {
|
|
|
|
+ $this->error(__('Mobile Captcha is incorrect'));
|
|
}
|
|
}
|
|
- $ret = Sms::check($mobile, $code, 'register');
|
|
|
|
|
|
+
|
|
|
|
+ $ret = Ems::check($email, $emailcaptcha, 'register');
|
|
if (!$ret) {
|
|
if (!$ret) {
|
|
- $this->error(__('Captcha is incorrect'));
|
|
|
|
|
|
+ $this->error(__('Email Captcha is incorrect'));
|
|
}
|
|
}
|
|
- $ret = $this->auth->register($username, $password, $email, $mobile, []);
|
|
|
|
|
|
+
|
|
|
|
+ $extend = [
|
|
|
|
+ 'firstname' => $firstname,
|
|
|
|
+ 'lastname' => $lastname,
|
|
|
|
+ 'simplemobile' => $mobile,
|
|
|
|
+ 'height' => input('height',''),
|
|
|
|
+ 'age' => input('age',''),
|
|
|
|
+ 'weight' => input('weight',''),
|
|
|
|
+ 'address' => input('address',''),
|
|
|
|
+ ];
|
|
|
|
+ $ret = $this->auth->register('', $password, $email, $fullmobile, $extend);
|
|
if ($ret) {
|
|
if ($ret) {
|
|
- $data = ['userinfo' => $this->auth->getUserinfo()];
|
|
|
|
|
|
+ $data = $this->auth->getUserinfo();
|
|
$this->success(__('Sign up successful'), $data);
|
|
$this->success(__('Sign up successful'), $data);
|
|
} else {
|
|
} else {
|
|
$this->error($this->auth->getError());
|
|
$this->error($this->auth->getError());
|