mirror of
https://github.com/open-webui/open-webui
synced 2025-05-15 19:16:35 +00:00
enh: remove token cookie on signout
This commit is contained in:
parent
6b620d93a9
commit
e9e49babf8
@ -323,6 +323,12 @@ async def signup(request: Request, response: Response, form_data: SignupForm):
|
|||||||
raise HTTPException(500, detail=ERROR_MESSAGES.DEFAULT(err))
|
raise HTTPException(500, detail=ERROR_MESSAGES.DEFAULT(err))
|
||||||
|
|
||||||
|
|
||||||
|
@router.get("/signout")
|
||||||
|
async def signout(response: Response):
|
||||||
|
response.delete_cookie("token")
|
||||||
|
return {"status": True}
|
||||||
|
|
||||||
|
|
||||||
############################
|
############################
|
||||||
# AddUser
|
# AddUser
|
||||||
############################
|
############################
|
||||||
|
@ -180,6 +180,31 @@ export const userSignUp = async (
|
|||||||
return res;
|
return res;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const userSignOut = async () => {
|
||||||
|
let error = null;
|
||||||
|
|
||||||
|
const res = await fetch(`${WEBUI_API_BASE_URL}/auths/signout`, {
|
||||||
|
method: 'GET',
|
||||||
|
headers: {
|
||||||
|
'Content-Type': 'application/json'
|
||||||
|
},
|
||||||
|
credentials: 'include'
|
||||||
|
})
|
||||||
|
.then(async (res) => {
|
||||||
|
if (!res.ok) throw await res.json();
|
||||||
|
return res;
|
||||||
|
})
|
||||||
|
.catch((err) => {
|
||||||
|
console.log(err);
|
||||||
|
error = err.detail;
|
||||||
|
return null;
|
||||||
|
});
|
||||||
|
|
||||||
|
if (error) {
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
export const addUser = async (
|
export const addUser = async (
|
||||||
token: string,
|
token: string,
|
||||||
name: string,
|
name: string,
|
||||||
|
@ -8,6 +8,7 @@
|
|||||||
import { showSettings, activeUserCount, USAGE_POOL, mobile, showSidebar } from '$lib/stores';
|
import { showSettings, activeUserCount, USAGE_POOL, mobile, showSidebar } from '$lib/stores';
|
||||||
import { fade, slide } from 'svelte/transition';
|
import { fade, slide } from 'svelte/transition';
|
||||||
import Tooltip from '$lib/components/common/Tooltip.svelte';
|
import Tooltip from '$lib/components/common/Tooltip.svelte';
|
||||||
|
import { userSignOut } from '$lib/apis/auths';
|
||||||
|
|
||||||
const i18n = getContext('i18n');
|
const i18n = getContext('i18n');
|
||||||
|
|
||||||
@ -154,7 +155,8 @@
|
|||||||
|
|
||||||
<button
|
<button
|
||||||
class="flex rounded-md py-2 px-3 w-full hover:bg-gray-50 dark:hover:bg-gray-800 transition"
|
class="flex rounded-md py-2 px-3 w-full hover:bg-gray-50 dark:hover:bg-gray-800 transition"
|
||||||
on:click={() => {
|
on:click={async () => {
|
||||||
|
await userSignOut();
|
||||||
localStorage.removeItem('token');
|
localStorage.removeItem('token');
|
||||||
location.href = '/auth';
|
location.href = '/auth';
|
||||||
show = false;
|
show = false;
|
||||||
|
Loading…
Reference in New Issue
Block a user