Skip to content

Commit 509106a

Browse files
committed
feat: support auth proxy login mode(logout)
Signed-off-by: BobDu <[email protected]>
1 parent dc27597 commit 509106a

File tree

3 files changed

+13
-1
lines changed

3 files changed

+13
-1
lines changed

service/src/index.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -761,6 +761,10 @@ router.post('/user-login', authLimiter, async (req, res) => {
761761
}
762762
})
763763

764+
router.post('/user-logout', auth, async (req, res) => {
765+
res.send({ status: 'Success', message: '退出登录成功 | Logout successful', data: null })
766+
})
767+
764768
router.post('/user-send-reset-mail', authLimiter, async (req, res) => {
765769
try {
766770
const { username } = req.body as { username: string }

src/api/index.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,13 @@ export function fetchLogin<T = any>(username: string, password: string, token?:
8989
})
9090
}
9191

92+
export function fetchLogout<T = any>() {
93+
return post<T>({
94+
url: '/user-logout',
95+
data: { },
96+
})
97+
}
98+
9299
export function fetchSendResetMail<T = any>(username: string) {
93100
return post<T>({
94101
url: '/user-send-reset-mail',

src/store/modules/auth/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import jwt_decode from 'jwt-decode'
33
import type { UserInfo } from '../user/helper'
44
import { getToken, removeToken, setToken } from './helper'
55
import { store, useChatStore, useUserStore } from '@/store'
6-
import { fetchSession } from '@/api'
6+
import { fetchLogout, fetchSession } from '@/api'
77
import { UserConfig } from '@/components/common/Setting/model'
88

99
interface SessionResponse {
@@ -81,6 +81,7 @@ export const useAuthStore = defineStore('auth-store', {
8181
const chatStore = useChatStore()
8282
await chatStore.clearLocalChat()
8383
removeToken()
84+
await fetchLogout()
8485
},
8586
},
8687
})

0 commit comments

Comments
 (0)