|
@@ -40,32 +40,6 @@ class User extends Api
|
|
|
$this->success('', ['welcome' => $this->auth->nickname]);
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * 会员登录
|
|
|
- *
|
|
|
- * @ApiMethod (POST)
|
|
|
- * @param string $account 账号
|
|
|
- * @param string $password 密码
|
|
|
- */
|
|
|
- public function login()
|
|
|
- {
|
|
|
- $countrycode = input('countrycode',86,'intval');
|
|
|
- $account = input('account');
|
|
|
- $password = input('password');
|
|
|
-
|
|
|
- if (!$countrycode || !$account || !$password) {
|
|
|
- $this->error(__('Invalid parameters'));
|
|
|
- }
|
|
|
-
|
|
|
- $account = $countrycode.$account;
|
|
|
- $ret = $this->auth->login($account, $password);
|
|
|
- if ($ret) {
|
|
|
- $data = $this->userInfo('return');
|
|
|
- $this->success(__('Logged in successful'), $data);
|
|
|
- } else {
|
|
|
- $this->error($this->auth->getError());
|
|
|
- }
|
|
|
- }
|
|
|
|
|
|
|
|
|
/**
|
|
@@ -77,18 +51,16 @@ class User extends Api
|
|
|
*/
|
|
|
public function mobilelogin()
|
|
|
{
|
|
|
- $countrycode = input('countrycode',86,'intval');
|
|
|
$mobile = input('mobile');
|
|
|
$captcha = input('captcha');
|
|
|
|
|
|
- if (!$countrycode || !$mobile || !$captcha) {
|
|
|
+ if (!$mobile || !$captcha) {
|
|
|
$this->error(__('Invalid parameters'));
|
|
|
}
|
|
|
- /*if (!Validate::regex($mobile, "^1\d{10}$")) {
|
|
|
+ if (!Validate::regex($mobile, "^1\d{10}$")) {
|
|
|
$this->error(__('Mobile is incorrect'));
|
|
|
- }*/
|
|
|
- $simplemobile = $mobile;
|
|
|
- $mobile = $countrycode.$mobile;
|
|
|
+ }
|
|
|
+
|
|
|
if (!Sms::check($mobile, $captcha, 'mobilelogin')) {
|
|
|
$this->error(__('Captcha is incorrect'));
|
|
|
}
|
|
@@ -106,7 +78,6 @@ class User extends Api
|
|
|
|
|
|
} else {
|
|
|
$extend = [
|
|
|
- 'simplemobile' => $simplemobile,
|
|
|
];
|
|
|
$ret = $this->auth->register('', '', '', $mobile, $extend);
|
|
|
|
|
@@ -226,9 +197,6 @@ class User extends Api
|
|
|
} else {
|
|
|
// 取号成功, 执行登录等流程
|
|
|
// 用户登录逻辑 === 开始
|
|
|
- $countrycode = 86;
|
|
|
- $simplemobile = $mobile;
|
|
|
- $mobile = $countrycode.$mobile;
|
|
|
$user = \app\common\model\User::getByMobile($mobile);
|
|
|
if ($user) {
|
|
|
if ($user->status == -1) {
|
|
@@ -244,7 +212,6 @@ class User extends Api
|
|
|
|
|
|
} else {
|
|
|
$extend = [
|
|
|
- 'simplemobile' => $simplemobile,
|
|
|
];
|
|
|
$ret = $this->auth->register('', '', '', $mobile, $extend);
|
|
|
$is_register = 1;
|
|
@@ -540,17 +507,14 @@ class User extends Api
|
|
|
{
|
|
|
$user = $this->auth->getUser();
|
|
|
$oldcaptcha = $this->request->request('oldcaptcha');
|
|
|
- $countrycode = $this->request->request('countrycode',86,'intval');
|
|
|
$mobile = $this->request->request('mobile');
|
|
|
$captcha = $this->request->request('captcha');
|
|
|
- if (!$oldcaptcha || !$countrycode || !$mobile || !$captcha) {
|
|
|
+ if (!$oldcaptcha || !$mobile || !$captcha) {
|
|
|
$this->error(__('Invalid parameters'));
|
|
|
}
|
|
|
- /*if (!Validate::regex($mobile, "^1\d{10}$")) {
|
|
|
+ if (!Validate::regex($mobile, "^1\d{10}$")) {
|
|
|
$this->error(__('Mobile is incorrect'));
|
|
|
- }*/
|
|
|
- $simplemobile = $mobile;
|
|
|
- $mobile = $countrycode.$mobile;
|
|
|
+ }
|
|
|
if($user->mobile == $mobile){
|
|
|
$this->error('新手机号不能与旧手机号相同');
|
|
|
}
|
|
@@ -570,7 +534,6 @@ class User extends Api
|
|
|
Sms::flush($mobile, 'changemobile');
|
|
|
|
|
|
$user->mobile = $mobile;
|
|
|
- $user->simplemobile = $simplemobile;
|
|
|
$user->save();
|
|
|
|
|
|
$this->success();
|
|
@@ -585,19 +548,16 @@ class User extends Api
|
|
|
*/
|
|
|
public function applebindmobile()
|
|
|
{
|
|
|
- $countrycode = $this->request->request('countrycode',86,'intval');
|
|
|
$mobile = $this->request->param('mobile');
|
|
|
$captcha = $this->request->param('captcha');
|
|
|
$iosUserId = $this->request->param('ios_user_id','');
|
|
|
|
|
|
- if (!$countrycode || !$mobile || !$captcha || !$iosUserId) {
|
|
|
+ if (!$mobile || !$captcha || !$iosUserId) {
|
|
|
$this->error(__('Invalid parameters'));
|
|
|
}
|
|
|
- /*if (!Validate::regex($mobile, "^1\d{10}$")) {
|
|
|
+ if (!Validate::regex($mobile, "^1\d{10}$")) {
|
|
|
$this->error(__('Mobile is incorrect'));
|
|
|
- }*/
|
|
|
- $simplemobile = $mobile;
|
|
|
- $mobile = $countrycode.$mobile;
|
|
|
+ }
|
|
|
$result = Sms::check($mobile, $captcha, 'changemobile');
|
|
|
if (!$result) {
|
|
|
$this->error(__('Captcha is incorrect'));
|
|
@@ -635,7 +595,6 @@ class User extends Api
|
|
|
} else {
|
|
|
$extend = [
|
|
|
'ios_user_id' => $iosUserId,
|
|
|
- 'simplemobile' => $simplemobile,
|
|
|
];
|
|
|
$ret = $this->auth->register('', '','', $mobile, $extend);
|
|
|
}
|
|
@@ -656,19 +615,16 @@ class User extends Api
|
|
|
*/
|
|
|
public function bindmobile()
|
|
|
{
|
|
|
- $countrycode = $this->request->param('countrycode',86,'intval');
|
|
|
$mobile = $this->request->param('mobile');
|
|
|
$captcha = $this->request->param('captcha');
|
|
|
$code = $this->request->param('code');
|
|
|
|
|
|
- if (!$countrycode || !$mobile || !$captcha || !$code) {
|
|
|
+ if (!$mobile || !$captcha || !$code) {
|
|
|
$this->error(__('Invalid parameters'));
|
|
|
}
|
|
|
- /*if (!Validate::regex($mobile, "^1\d{10}$")) {
|
|
|
+ if (!Validate::regex($mobile, "^1\d{10}$")) {
|
|
|
$this->error(__('Mobile is incorrect'));
|
|
|
- }*/
|
|
|
- $simplemobile = $mobile;
|
|
|
- $mobile = $countrycode.$mobile;
|
|
|
+ }
|
|
|
$result = Sms::check($mobile, $captcha, 'changemobile');
|
|
|
if (!$result) {
|
|
|
$this->error(__('Captcha is incorrect'));
|
|
@@ -710,7 +666,6 @@ class User extends Api
|
|
|
} else {
|
|
|
$extend = [
|
|
|
'wechat_openid' => $wechatCode['openid'],
|
|
|
- 'simplemobile' => $simplemobile,
|
|
|
];
|
|
|
$ret = $this->auth->register('', '','', $mobile, $extend);
|
|
|
}
|
|
@@ -765,20 +720,18 @@ class User extends Api
|
|
|
{
|
|
|
//$type = input("type");
|
|
|
$type = 'mobile';
|
|
|
- $countrycode = input("countrycode",86,'intval');
|
|
|
$mobile = input("mobile");
|
|
|
// $email = input("email");
|
|
|
$newpassword = input("newpassword");
|
|
|
$captcha = input("captcha");
|
|
|
- if (!$countrycode || !$mobile || !$newpassword || !$captcha) {
|
|
|
+ if (!$mobile || !$newpassword || !$captcha) {
|
|
|
$this->error(__('Invalid parameters'));
|
|
|
}
|
|
|
|
|
|
- $mobile = $countrycode.$mobile;
|
|
|
if ($type == 'mobile') {
|
|
|
- /*if (!Validate::regex($mobile, "^1\d{10}$")) {
|
|
|
+ if (!Validate::regex($mobile, "^1\d{10}$")) {
|
|
|
$this->error(__('Mobile is incorrect'));
|
|
|
- }*/
|
|
|
+ }
|
|
|
$user = \app\common\model\User::getByMobile($mobile);
|
|
|
if (!$user) {
|
|
|
$this->error(__('User not found'));
|