优化:移动端商户登录时 需要判断商户类型,取消跨类型登录支持
This commit is contained in:
parent
27933547a9
commit
65a16c6289
|
|
@ -158,18 +158,18 @@ class MerchantAdminRepository extends BaseRepository
|
||||||
{
|
{
|
||||||
return password_hash($password, PASSWORD_BCRYPT);
|
return password_hash($password, PASSWORD_BCRYPT);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string $account
|
* @param string $account
|
||||||
* @param string $password
|
* @param string $password
|
||||||
|
* @param int $merchantType
|
||||||
* @return array|Model|null
|
* @return array|Model|null
|
||||||
* @throws DataNotFoundException
|
* @throws DataNotFoundException
|
||||||
* @throws DbException
|
* @throws DbException
|
||||||
* @throws ModelNotFoundException
|
* @throws ModelNotFoundException
|
||||||
* @author xaboy
|
* @author xaboy
|
||||||
* @day 2020-04-17
|
* @day 2020-04-17
|
||||||
*/
|
*/
|
||||||
public function login(string $account, string $password)
|
public function login(string $account, string $password,int $merchantType = -1)
|
||||||
{
|
{
|
||||||
event('admin.merLogin.before',compact('account', 'password'));
|
event('admin.merLogin.before',compact('account', 'password'));
|
||||||
$accountInfo = explode('@', $account, 2);
|
$accountInfo = explode('@', $account, 2);
|
||||||
|
|
@ -195,8 +195,7 @@ class MerchantAdminRepository extends BaseRepository
|
||||||
throw new ValidateException('账号或密码错误');
|
throw new ValidateException('账号或密码错误');
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($adminInfo['status'] != 1)
|
if ($adminInfo['status'] != 1) throw new ValidateException('账号已关闭');
|
||||||
throw new ValidateException('账号已关闭');
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -206,6 +205,8 @@ class MerchantAdminRepository extends BaseRepository
|
||||||
$merchant = $merchantRepository->get($adminInfo->mer_id);
|
$merchant = $merchantRepository->get($adminInfo->mer_id);
|
||||||
if (!$merchant) throw new ValidateException('商户不存在');
|
if (!$merchant) throw new ValidateException('商户不存在');
|
||||||
if (!$merchant['status']) throw new ValidateException('商户已被锁定');
|
if (!$merchant['status']) throw new ValidateException('商户已被锁定');
|
||||||
|
// 判断:如果指定了登录的商户类别 则禁止跨类别登录
|
||||||
|
if($merchantType >= 0 && $merchant->merchant_type != $merchantType) throw new ValidateException('账号或密码错误');
|
||||||
|
|
||||||
$adminInfo->last_time = date('Y-m-d H:i:s');
|
$adminInfo->last_time = date('Y-m-d H:i:s');
|
||||||
$adminInfo->last_ip = app('request')->ip();
|
$adminInfo->last_ip = app('request')->ip();
|
||||||
|
|
|
||||||
|
|
@ -160,12 +160,12 @@ class Merchant extends BaseController
|
||||||
*/
|
*/
|
||||||
public function storeLogin(){
|
public function storeLogin(){
|
||||||
// 参数获取
|
// 参数获取
|
||||||
$params = $this->request->params(['account','password']);
|
$params = $this->request->params(['account','password','merchant_type']);
|
||||||
if(empty($params['account'])) throw new ValidateException('请输入账号');
|
if(empty($params['account'])) throw new ValidateException('请输入账号');
|
||||||
if(empty($params['password'])) throw new ValidateException('请输入密码');
|
if(empty($params['password'])) throw new ValidateException('请输入密码');
|
||||||
// 判断登录是否成功
|
// 判断登录是否成功
|
||||||
$repository = app()->make(MerchantAdminRepository::class);
|
$repository = app()->make(MerchantAdminRepository::class);
|
||||||
$adminInfo = $repository->login($params['account'], $params['password']);
|
$adminInfo = $repository->login($params['account'], $params['password'], $params['merchant_type']);
|
||||||
$tokenInfo = $repository->createToken($adminInfo);
|
$tokenInfo = $repository->createToken($adminInfo);
|
||||||
$admin = $adminInfo->toArray();
|
$admin = $adminInfo->toArray();
|
||||||
// 判断:这里仅允许酒道馆和普通商户登录
|
// 判断:这里仅允许酒道馆和普通商户登录
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue