up.
This commit is contained in:
parent
ab9af25691
commit
1959972234
@ -4,6 +4,8 @@ namespace app\controller\admin\auth;
|
|||||||
|
|
||||||
use app\BaseController;
|
use app\BaseController;
|
||||||
use app\entity\SysUser;
|
use app\entity\SysUser;
|
||||||
|
use app\enum\UserLoginEnum;
|
||||||
|
use app\service\admin\LoginService;
|
||||||
use think\db\exception\DataNotFoundException;
|
use think\db\exception\DataNotFoundException;
|
||||||
use think\db\exception\DbException;
|
use think\db\exception\DbException;
|
||||||
use think\db\exception\ModelNotFoundException;
|
use think\db\exception\ModelNotFoundException;
|
||||||
@ -35,6 +37,8 @@ class AuthController extends BaseController
|
|||||||
*/
|
*/
|
||||||
public function logout(): Json
|
public function logout(): Json
|
||||||
{
|
{
|
||||||
|
$srv = new LoginService();
|
||||||
|
$srv->logout($this->request, $this->auth->getUser());
|
||||||
return $this->writeSuccess('退出成功');
|
return $this->writeSuccess('退出成功');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -84,6 +84,10 @@ class LoginService
|
|||||||
'context_id' => $request->contextId,
|
'context_id' => $request->contextId,
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
public function logout(Request $request, SysUser $user)
|
||||||
|
{
|
||||||
|
$this->saveLoginRecord($request, $user->username,UserLoginEnum::LOGIN_EXIT, '退出登录');
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public function checkUserAccessToken(string $token): HttpAuth
|
public function checkUserAccessToken(string $token): HttpAuth
|
||||||
|
|||||||
@ -3,6 +3,17 @@ import type { ApiResult } from '@/api';
|
|||||||
import type { User } from '@/api/system/user/model';
|
import type { User } from '@/api/system/user/model';
|
||||||
import type { UpdatePasswordParam } from './model';
|
import type { UpdatePasswordParam } from './model';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 退出登录
|
||||||
|
*/
|
||||||
|
export async function userLogout() {
|
||||||
|
const res = await request.post<ApiResult<any>>('/auth/logout');
|
||||||
|
if (res.data.code === 0) {
|
||||||
|
return res.data.message;
|
||||||
|
}
|
||||||
|
return Promise.reject(new Error(res.data.message));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取当前登录用户的个人信息/菜单/权限/角色
|
* 获取当前登录用户的个人信息/菜单/权限/角色
|
||||||
*/
|
*/
|
||||||
|
|||||||
@ -2,6 +2,7 @@ import type { Router } from 'vue-router';
|
|||||||
import type { Action } from 'element-plus';
|
import type { Action } from 'element-plus';
|
||||||
import { ElMessageBox } from 'element-plus';
|
import { ElMessageBox } from 'element-plus';
|
||||||
import { removeToken } from '@/utils/token-util';
|
import { removeToken } from '@/utils/token-util';
|
||||||
|
import { userLogout } from '@/api/layout';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 退出登录
|
* 退出登录
|
||||||
@ -9,7 +10,12 @@ import { removeToken } from '@/utils/token-util';
|
|||||||
* @param from 登录后跳转的地址
|
* @param from 登录后跳转的地址
|
||||||
* @param push 路由跳转方法
|
* @param push 路由跳转方法
|
||||||
*/
|
*/
|
||||||
export function logout(route?: boolean, from?: string, push?: Router['push']) {
|
export async function logout(
|
||||||
|
route?: boolean,
|
||||||
|
from?: string,
|
||||||
|
push?: Router['push']
|
||||||
|
) {
|
||||||
|
await userLogout();
|
||||||
removeToken();
|
removeToken();
|
||||||
if (route && push) {
|
if (route && push) {
|
||||||
push({
|
push({
|
||||||
|
|||||||
@ -36,7 +36,10 @@
|
|||||||
type="danger"
|
type="danger"
|
||||||
:disable-transitions="true"
|
:disable-transitions="true"
|
||||||
>
|
>
|
||||||
登录失败 - {{ row.loginType }}
|
登录失败/<span v-if="row.loginType == 11">用户名错误</span>
|
||||||
|
<span v-if="row.loginType == 12">密码错误</span>
|
||||||
|
<span v-if="row.loginType == 21">用户已被禁用</span>
|
||||||
|
<span v-if="row.loginType == 31">登录异常</span>
|
||||||
</el-tag>
|
</el-tag>
|
||||||
</template>
|
</template>
|
||||||
</ele-pro-table>
|
</ele-pro-table>
|
||||||
@ -107,8 +110,7 @@
|
|||||||
{
|
{
|
||||||
prop: 'loginType',
|
prop: 'loginType',
|
||||||
label: '操作类型',
|
label: '操作类型',
|
||||||
sortable: 'custom',
|
width: 140,
|
||||||
width: 130,
|
|
||||||
slot: 'loginType',
|
slot: 'loginType',
|
||||||
filters: [
|
filters: [
|
||||||
{
|
{
|
||||||
@ -136,8 +138,7 @@
|
|||||||
value: '98'
|
value: '98'
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
filterMultiple: false,
|
filterMultiple: false
|
||||||
align: 'center'
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
prop: 'comments',
|
prop: 'comments',
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user