Merge branch 'dev' of https://gitea.lihaink.cn/mkm/multi-store into dev
This commit is contained in:
commit
a9be9ec500
@ -17,8 +17,7 @@ class LoginController extends BaseApiController
|
||||
*/
|
||||
public function account()
|
||||
{
|
||||
$params=$this->request->post();
|
||||
// $params = (new LoginAccountValidate())->post()->goCheck();
|
||||
$params = (new LoginAccountValidate())->post()->goCheck();
|
||||
$result = LoginLogic::login($params);
|
||||
if (false === $result) {
|
||||
return $this->fail(LoginLogic::getError());
|
||||
|
@ -18,6 +18,7 @@ use think\Exception;
|
||||
*/
|
||||
class UserController extends BaseApiController
|
||||
{
|
||||
public $notNeedLogin = ['login_sms'];
|
||||
// #[
|
||||
// ApiDoc\Title('获取小程序手机号'),
|
||||
// ApiDoc\url('/api/user/user/getMobileByMnp'),
|
||||
@ -143,6 +144,17 @@ class UserController extends BaseApiController
|
||||
}
|
||||
return $this->fail('发送失败');
|
||||
}
|
||||
|
||||
public function login_sms()
|
||||
{
|
||||
$params = (new UserValidate())->post()->goCheck('login');
|
||||
$res = (new UserLogic())->dealLoginSms($params['account']);
|
||||
if ($res){
|
||||
return $this->success('发送成功');
|
||||
}
|
||||
return $this->fail('发送失败');
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@ -188,6 +188,21 @@ class UserLogic extends BaseLogic
|
||||
}
|
||||
|
||||
|
||||
public function dealLoginSms($phone)
|
||||
{
|
||||
$code = generateRandomCode();
|
||||
$template = getenv('SMS_LOGIN_TEMPLATE');
|
||||
$check =(new SmsService())->client($phone,$template,$code);
|
||||
if($check){
|
||||
$remark = $phone.'_login';
|
||||
Cache::set($remark,$code,5*60);
|
||||
return true;
|
||||
}else{
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -5,12 +5,15 @@ namespace app\api\validate;
|
||||
use app\common\cache\UserAccountSafeCache;
|
||||
use app\common\enum\LoginEnum;
|
||||
use app\common\enum\notice\NoticeEnum;
|
||||
use app\common\enum\PayEnum;
|
||||
use app\common\enum\user\UserTerminalEnum;
|
||||
use app\common\enum\YesNoEnum;
|
||||
use app\common\service\ConfigService;
|
||||
use app\common\service\sms\SmsDriver;
|
||||
use app\common\validate\BaseValidate;
|
||||
use app\common\model\user\User;
|
||||
use support\Cache;
|
||||
use think\Exception;
|
||||
use Webman\Config;
|
||||
/**
|
||||
* 账号密码登录校验
|
||||
@ -138,10 +141,20 @@ class LoginAccountValidate extends BaseValidate
|
||||
*/
|
||||
public function checkCode($code, $rule, $data)
|
||||
{
|
||||
$remark = $data['account'].'_login';
|
||||
$code = Cache::get($remark);
|
||||
if(empty($code)){
|
||||
return '验证码不存在';
|
||||
}
|
||||
if (isset($data['code']) && $code != $data['code']) {
|
||||
return '验证码错误';
|
||||
}
|
||||
return true;
|
||||
|
||||
// $smsDriver = new SmsDriver();
|
||||
// $result = $smsDriver->verify($data['account'], $code, NoticeEnum::LOGIN_CAPTCHA);
|
||||
// if ($result) {
|
||||
// return true;
|
||||
// return true;
|
||||
// }
|
||||
// return '验证码错误';
|
||||
}
|
||||
|
@ -22,6 +22,7 @@ class UserValidate extends BaseValidate
|
||||
'password' => 'require',
|
||||
'rePassword' => 'require',
|
||||
'type' => 'require',
|
||||
'account' => 'require',
|
||||
|
||||
];
|
||||
|
||||
@ -30,11 +31,19 @@ class UserValidate extends BaseValidate
|
||||
'store_id.require' => '门店id',
|
||||
'mobile.require' => '手机',
|
||||
'phone.require' => '手机',
|
||||
'account.require' => '手机',
|
||||
'password.require' => '密码',
|
||||
'rePassword.require' => '确认密码',
|
||||
'type' => '查询类型',
|
||||
];
|
||||
|
||||
|
||||
public function sceneLogin()
|
||||
{
|
||||
return $this->only(['account']);
|
||||
|
||||
}
|
||||
|
||||
public function sceneFund()
|
||||
{
|
||||
return $this->only(['type']);
|
||||
|
Loading…
x
Reference in New Issue
Block a user