|
@@ -49,11 +49,15 @@ class User extends Api
|
|
|
*/
|
|
|
public function login()
|
|
|
{
|
|
|
+ $countrycode = input('countrycode');
|
|
|
$account = input('account');
|
|
|
$password = input('password');
|
|
|
- if (!$account || !$password) {
|
|
|
+
|
|
|
+ if (!$countrycode || !$account || !$password) {
|
|
|
$this->error(__('Invalid parameters'));
|
|
|
}
|
|
|
+
|
|
|
+ $account = $countrycode.$account;
|
|
|
$ret = $this->auth->login($account, $password);
|
|
|
if ($ret) {
|
|
|
$data = $this->userInfo('return');
|
|
@@ -73,16 +77,17 @@ class User extends Api
|
|
|
*/
|
|
|
public function mobilelogin()
|
|
|
{
|
|
|
-
|
|
|
+ $countrycode = input('countrycode');
|
|
|
$mobile = input('mobile');
|
|
|
$captcha = input('captcha');
|
|
|
|
|
|
- if (!$mobile || !$captcha) {
|
|
|
+ if (!$countrycode || !$mobile || !$captcha) {
|
|
|
$this->error(__('Invalid parameters'));
|
|
|
}
|
|
|
/*if (!Validate::regex($mobile, "^1\d{10}$")) {
|
|
|
$this->error(__('Mobile is incorrect'));
|
|
|
}*/
|
|
|
+ $mobile = $countrycode.$mobile;
|
|
|
if (!Sms::check($mobile, $captcha, 'mobilelogin')) {
|
|
|
$this->error(__('Captcha is incorrect'));
|
|
|
}
|
|
@@ -257,7 +262,8 @@ class User extends Api
|
|
|
} else {
|
|
|
// 取号成功, 执行登录等流程
|
|
|
// 用户登录逻辑 === 开始
|
|
|
-
|
|
|
+ $countrycode = 86;
|
|
|
+ $mobile = $countrycode.$mobile;
|
|
|
$user = \app\common\model\User::getByMobile($mobile);
|
|
|
if ($user) {
|
|
|
if ($user->status == -1) {
|
|
@@ -548,14 +554,16 @@ class User extends Api
|
|
|
{
|
|
|
$user = $this->auth->getUser();
|
|
|
$oldcaptcha = $this->request->request('oldcaptcha');
|
|
|
+ $countrycode = $this->request->request('countrycode');
|
|
|
$mobile = $this->request->request('mobile');
|
|
|
$captcha = $this->request->request('captcha');
|
|
|
- if (!$oldcaptcha || !$mobile || !$captcha) {
|
|
|
+ if (!$oldcaptcha || !$countrycode || !$mobile || !$captcha) {
|
|
|
$this->error(__('Invalid parameters'));
|
|
|
}
|
|
|
/*if (!Validate::regex($mobile, "^1\d{10}$")) {
|
|
|
$this->error(__('Mobile is incorrect'));
|
|
|
}*/
|
|
|
+ $mobile = $countrycode.$mobile;
|
|
|
if($user->mobile == $mobile){
|
|
|
$this->error('新手机号不能与旧手机号相同');
|
|
|
}
|
|
@@ -590,16 +598,18 @@ class User extends Api
|
|
|
*/
|
|
|
public function applebindmobile()
|
|
|
{
|
|
|
+ $countrycode = $this->request->request('countrycode');
|
|
|
$mobile = $this->request->param('mobile');
|
|
|
$captcha = $this->request->param('captcha');
|
|
|
$iosUserId = $this->request->param('ios_user_id','');
|
|
|
|
|
|
- if (!$mobile || !$captcha || !$iosUserId) {
|
|
|
+ if (!$countrycode || !$mobile || !$captcha || !$iosUserId) {
|
|
|
$this->error(__('Invalid parameters'));
|
|
|
}
|
|
|
/*if (!Validate::regex($mobile, "^1\d{10}$")) {
|
|
|
$this->error(__('Mobile is incorrect'));
|
|
|
}*/
|
|
|
+ $mobile = $countrycode.$mobile;
|
|
|
$result = Sms::check($mobile, $captcha, 'changemobile');
|
|
|
if (!$result) {
|
|
|
$this->error(__('Captcha is incorrect'));
|
|
@@ -656,16 +666,18 @@ class User extends Api
|
|
|
*/
|
|
|
public function bindmobile()
|
|
|
{
|
|
|
+ $countrycode = $this->request->param('countrycode');
|
|
|
$mobile = $this->request->param('mobile');
|
|
|
$captcha = $this->request->param('captcha');
|
|
|
$code = $this->request->param('code');
|
|
|
|
|
|
- if (!$mobile || !$captcha || !$code) {
|
|
|
+ if (!$countrycode || !$mobile || !$captcha || !$code) {
|
|
|
$this->error(__('Invalid parameters'));
|
|
|
}
|
|
|
/*if (!Validate::regex($mobile, "^1\d{10}$")) {
|
|
|
$this->error(__('Mobile is incorrect'));
|
|
|
}*/
|
|
|
+ $mobile = $countrycode.$mobile;
|
|
|
$result = Sms::check($mobile, $captcha, 'changemobile');
|
|
|
if (!$result) {
|
|
|
$this->error(__('Captcha is incorrect'));
|
|
@@ -760,13 +772,16 @@ class User extends Api
|
|
|
{
|
|
|
//$type = input("type");
|
|
|
$type = 'mobile';
|
|
|
+ $countrycode = input("countrycode");
|
|
|
$mobile = input("mobile");
|
|
|
- $email = input("email");
|
|
|
+// $email = input("email");
|
|
|
$newpassword = input("newpassword");
|
|
|
$captcha = input("captcha");
|
|
|
- if (!$newpassword || !$captcha) {
|
|
|
+ if (!$countrycode || !$mobile || !$newpassword || !$captcha) {
|
|
|
$this->error(__('Invalid parameters'));
|
|
|
}
|
|
|
+
|
|
|
+ $mobile = $countrycode.$mobile;
|
|
|
if ($type == 'mobile') {
|
|
|
/*if (!Validate::regex($mobile, "^1\d{10}$")) {
|
|
|
$this->error(__('Mobile is incorrect'));
|
|
@@ -780,19 +795,6 @@ class User extends Api
|
|
|
$this->error(__('Captcha is incorrect'));
|
|
|
}
|
|
|
Sms::flush($mobile, 'resetpwd');
|
|
|
- } else {
|
|
|
- if (!Validate::is($email, "email")) {
|
|
|
- $this->error(__('Email is incorrect'));
|
|
|
- }
|
|
|
- $user = \app\common\model\User::getByEmail($email);
|
|
|
- if (!$user) {
|
|
|
- $this->error(__('User not found'));
|
|
|
- }
|
|
|
- $ret = Ems::check($email, $captcha, 'resetpwd');
|
|
|
- if (!$ret) {
|
|
|
- $this->error(__('Captcha is incorrect'));
|
|
|
- }
|
|
|
- Ems::flush($email, 'resetpwd');
|
|
|
}
|
|
|
//模拟一次登录
|
|
|
$this->auth->direct($user->id);
|