|
@@ -31,7 +31,7 @@ use TencentCloud\Iai\V20200303\Models\CompareFaceRequest;
|
|
*/
|
|
*/
|
|
class User extends Api
|
|
class User extends Api
|
|
{
|
|
{
|
|
- protected $noNeedLogin = ['emaillogin','emailregister','mobilelogin'];
|
|
|
|
|
|
+ protected $noNeedLogin = ['emaillogin','emailregister','mobilelogin','resetpwd'];
|
|
protected $noNeedRight = '*';
|
|
protected $noNeedRight = '*';
|
|
|
|
|
|
public function _initialize()
|
|
public function _initialize()
|
|
@@ -39,25 +39,9 @@ class User extends Api
|
|
parent::_initialize();
|
|
parent::_initialize();
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+
|
|
/**
|
|
/**
|
|
- * 会员中心
|
|
|
|
- */
|
|
|
|
- /*public function index()
|
|
|
|
- {
|
|
|
|
- $this->success('', ['welcome' => $this->auth->nickname]);
|
|
|
|
- }*/
|
|
|
|
- /**
|
|
|
|
- * 获取美颜授权
|
|
|
|
- *
|
|
|
|
- */
|
|
|
|
- /*public function getmeiyan()
|
|
|
|
- {
|
|
|
|
- $code = Db::name('Config')->where(['name'=>'meiyan'])->value('value');
|
|
|
|
- $rs['code'] = $code;
|
|
|
|
- $this->success('请求成功',$code);
|
|
|
|
- }*/
|
|
|
|
- /**
|
|
|
|
- * 会员登录
|
|
|
|
|
|
+ * 邮箱登录
|
|
*
|
|
*
|
|
* @ApiMethod (POST)
|
|
* @ApiMethod (POST)
|
|
* @param string $account 账号
|
|
* @param string $account 账号
|
|
@@ -80,6 +64,8 @@ class User extends Api
|
|
$this->error($this->auth->getError());
|
|
$this->error($this->auth->getError());
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ //邮箱注册
|
|
public function emailregister()
|
|
public function emailregister()
|
|
{
|
|
{
|
|
$account = input('account');
|
|
$account = input('account');
|
|
@@ -91,6 +77,11 @@ class User extends Api
|
|
if (!Validate::is($account, 'email')) {
|
|
if (!Validate::is($account, 'email')) {
|
|
$this->error(__('Email is incorrect'));
|
|
$this->error(__('Email is incorrect'));
|
|
}
|
|
}
|
|
|
|
+ $ret = Ems::check($account, $captcha, 'register');
|
|
|
|
+ if (!$ret) {
|
|
|
|
+ $this->error(__('Captcha is incorrect'));
|
|
|
|
+ }
|
|
|
|
+
|
|
$extend = [
|
|
$extend = [
|
|
'register_from' => input('register_from',''),
|
|
'register_from' => input('register_from',''),
|
|
'gender' => -1
|
|
'gender' => -1
|
|
@@ -107,7 +98,7 @@ class User extends Api
|
|
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
- * 手机验证码登录
|
|
|
|
|
|
+ * 手机验证码登录 + 注册
|
|
*
|
|
*
|
|
* @ApiMethod (POST)
|
|
* @ApiMethod (POST)
|
|
* @param string $mobile 手机号
|
|
* @param string $mobile 手机号
|
|
@@ -162,6 +153,63 @@ class User extends Api
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
|
|
+ * 重置密码
|
|
|
|
+ *
|
|
|
|
+ * @ApiMethod (POST)
|
|
|
|
+ * @param string $mobile 手机号
|
|
|
|
+ * @param string $newpassword 新密码
|
|
|
|
+ * @param string $captcha 验证码
|
|
|
|
+ */
|
|
|
|
+ public function resetpwd()
|
|
|
|
+ {
|
|
|
|
+ //$type = input("type");
|
|
|
|
+ $type = 'email';
|
|
|
|
+ $mobile = input("mobile");
|
|
|
|
+ $email = input("email");
|
|
|
|
+ $newpassword = input("newpassword");
|
|
|
|
+ $captcha = input("captcha");
|
|
|
|
+ if (!$newpassword || !$captcha) {
|
|
|
|
+ $this->error(__('Invalid parameters'));
|
|
|
|
+ }
|
|
|
|
+ if ($type == 'mobile') {
|
|
|
|
+ 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'));
|
|
|
|
+ }
|
|
|
|
+ $ret = Sms::check($mobile, $captcha, 'resetpwd');
|
|
|
|
+ if (!$ret) {
|
|
|
|
+ $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);
|
|
|
|
+ $ret = $this->auth->changepwd($newpassword, '', true);
|
|
|
|
+ if ($ret) {
|
|
|
|
+ $this->success(__('Reset password successful'));
|
|
|
|
+ } else {
|
|
|
|
+ $this->error($this->auth->getError());
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ /**
|
|
* 手机验证码验证
|
|
* 手机验证码验证
|
|
*
|
|
*
|
|
* @ApiMethod (POST)
|
|
* @ApiMethod (POST)
|
|
@@ -1000,61 +1048,7 @@ class User extends Api
|
|
|
|
|
|
|
|
|
|
|
|
|
|
- /**
|
|
|
|
- * 重置密码
|
|
|
|
- *
|
|
|
|
- * @ApiMethod (POST)
|
|
|
|
- * @param string $mobile 手机号
|
|
|
|
- * @param string $newpassword 新密码
|
|
|
|
- * @param string $captcha 验证码
|
|
|
|
- */
|
|
|
|
- public function resetpwd()
|
|
|
|
- {
|
|
|
|
- //$type = input("type");
|
|
|
|
- $type = 'mobile';
|
|
|
|
- $mobile = input("mobile");
|
|
|
|
- $email = input("email");
|
|
|
|
- $newpassword = input("newpassword");
|
|
|
|
- $captcha = input("captcha");
|
|
|
|
- if (!$newpassword || !$captcha) {
|
|
|
|
- $this->error(__('Invalid parameters'));
|
|
|
|
- }
|
|
|
|
- if ($type == 'mobile') {
|
|
|
|
- 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'));
|
|
|
|
- }
|
|
|
|
- $ret = Sms::check($mobile, $captcha, 'resetpwd');
|
|
|
|
- if (!$ret) {
|
|
|
|
- $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);
|
|
|
|
- $ret = $this->auth->changepwd($newpassword, '', true);
|
|
|
|
- if ($ret) {
|
|
|
|
- $this->success(__('Reset password successful'));
|
|
|
|
- } else {
|
|
|
|
- $this->error($this->auth->getError());
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
|
|
+
|
|
|
|
|
|
/**
|
|
/**
|
|
* 修改密码
|
|
* 修改密码
|