File tree Expand file tree Collapse file tree 3 files changed +27
-12
lines changed
packages/console/app/src/routes Expand file tree Collapse file tree 3 files changed +27
-12
lines changed Original file line number Diff line number Diff line change 1+ import { redirect } from "@solidjs/router"
2+ import { APIEvent } from "@solidjs/start"
3+ import { getResponseHeaders } from "@solidjs/start/http"
4+ import { useAuthSession } from "~/context/auth.session"
5+
6+ export async function GET ( event : APIEvent ) {
7+ const auth = await useAuthSession ( )
8+ const current = auth . data . current
9+ if ( current )
10+ await auth . update ( ( val ) => {
11+ delete val . account ?. [ current ]
12+ const first = Object . keys ( val . account ?? { } ) [ 0 ]
13+ val . current = first
14+ event ! . locals . actor = undefined
15+ return val
16+ } )
17+ return redirect ( "/zen" , {
18+ status : 302 ,
19+ headers : getResponseHeaders ( ) ,
20+ } )
21+ }
Original file line number Diff line number Diff line change 1212
1313 [data-slot = "item" ] {
1414 color : var (--color-danger );
15+ text-decoration : none;
1516 }
1617 }
1718}
Original file line number Diff line number Diff line change 1- import { action , redirect } from "@solidjs/router"
1+ import { action } from "@solidjs/router"
22import { getRequestEvent } from "solid-js/web"
33import { useAuthSession } from "~/context/auth.session"
44import { Dropdown } from "~/component/dropdown"
55import "./user-menu.css"
6- import { getResponseHeaders } from "@solidjs/start/http"
76
87const logout = action ( async ( ) => {
98 "use server"
@@ -18,21 +17,15 @@ const logout = action(async () => {
1817 event ! . locals . actor = undefined
1918 return val
2019 } )
21- throw redirect ( "/zen" , {
22- status : 302 ,
23- headers : getResponseHeaders ( ) ,
24- } )
25- } )
20+ } , "auth.logout" )
2621
2722export function UserMenu ( props : { email : string | null | undefined } ) {
2823 return (
2924 < div data-component = "user-menu" >
3025 < Dropdown trigger = { props . email ?? "" } align = "right" >
31- < form action = { logout } method = "post" >
32- < button type = "submit" formaction = { logout } data-slot = "item" >
33- Logout
34- </ button >
35- </ form >
26+ < a href = "/auth/logout" data-slot = "item" >
27+ Logout
28+ </ a >
3629 </ Dropdown >
3730 </ div >
3831 )
You can’t perform that action at this time.
0 commit comments