前端目录调整
This commit is contained in:
36
app/services/auth/LoginService.php
Normal file
36
app/services/auth/LoginService.php
Normal file
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | SentCMS [ WE CAN DO IT JUST THINK IT ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2013 http://www.tensent.cn All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: molong <molong@tensent.cn> <http://www.tensent.cn>
|
||||
// +----------------------------------------------------------------------
|
||||
namespace app\services\auth;
|
||||
|
||||
use app\model\user\Users;
|
||||
|
||||
class LoginService{
|
||||
|
||||
public function authLogin($request){
|
||||
$params = $request->post();
|
||||
$map = [];
|
||||
foreach($params as $field => $value){
|
||||
if(in_array($field, ['username', 'email', 'mobile']) && $field != 'password'){
|
||||
$map[$field] = $value;
|
||||
}
|
||||
}
|
||||
$user = Users::where($map)->field(['uid','username', 'password', 'email', 'avatar', 'department_id', 'status'])->findOrEmpty();
|
||||
if (!$user->isEmpty()) {
|
||||
if(password_verify(base64_decode($params['password']), $user->password)){
|
||||
throw new \think\Exception('密码不正确!', 100002);
|
||||
}elseif($user->status != 1){
|
||||
throw new \think\Exception('当前用户不可用', 100003);
|
||||
}else{
|
||||
return $user->append(['token']);
|
||||
}
|
||||
}else{
|
||||
throw new \think\Exception('当前用户不存在', 100001);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user