File tree Expand file tree Collapse file tree 6 files changed +44
-3
lines changed
Expand file tree Collapse file tree 6 files changed +44
-3
lines changed Original file line number Diff line number Diff line change 11"""Routes"""
22
3- from . import chat
3+ from . import chat , logout
44
5- __all__ = ("chat" ,)
5+ __all__ = ("chat" , "logout" )
Original file line number Diff line number Diff line change 1+ """Web chat"""
2+
3+ # stdlib
4+ from typing import Annotated
5+
6+ # 3rd party
7+ from fastapi import Depends , HTTPException
8+
9+ # api
10+ from xthulu .models .user import User
11+ from xthulu .web .auth import login_user
12+
13+ # local
14+ from .. import api
15+
16+
17+ @api .get ("/logout/" )
18+ def chat (user : Annotated [User , Depends (login_user )]):
19+ """End the user session."""
20+
21+ raise HTTPException (status_code = 401 )
Original file line number Diff line number Diff line change @@ -10,7 +10,10 @@ <h1>xthulu</h1>
1010 < h2 > Pages</ h2 >
1111 < ul >
1212 < li >
13- < a href ="chat/ "> Chat</ a >
13+ < a href ="/chat/ "> Chat</ a >
14+ </ li >
15+ < li >
16+ < a href ="/logout/ "> Logout</ a >
1417 </ li >
1518 </ ul >
1619 </ body >
Original file line number Diff line number Diff line change 1+ <!doctype html>
2+ < html lang ="en ">
3+ < head >
4+ < meta charset ="utf-8 " />
5+ < title > xthulu logout</ title >
6+ < meta name ="viewport " content ="width=device-width,initial-scale=1 " />
7+ </ head >
8+ < body >
9+ < p > Cancel any login prompt in order to clear your credentials.</ p >
10+ < p >
11+ < a href ="/ "> Home</ a >
12+ </ p >
13+ < script type ="module " src ="script.ts "> </ script >
14+ </ body >
15+ </ html >
Original file line number Diff line number Diff line change 1+ await fetch ( "/api/logout/" ) . then ( ( ) => window . location . assign ( "/" ) ) ;
Original file line number Diff line number Diff line change @@ -9,6 +9,7 @@ export default defineConfig({
99 input : {
1010 chat : resolve ( __dirname , "chat/index.html" ) ,
1111 index : resolve ( __dirname , "index.html" ) ,
12+ logout : resolve ( __dirname , "logout/index.html" ) ,
1213 } ,
1314 } ,
1415 target : "esnext" ,
You can’t perform that action at this time.
0 commit comments