fixed logout, now using account/app/server architecture
This commit is contained in:
		
							parent
							
								
									7f993ee538
								
							
						
					
					
						commit
						5e44cdf73a
					
				
					 1 changed files with 19 additions and 1 deletions
				
			
		|  | @ -1,5 +1,8 @@ | |||
| <script> | ||||
|     import * as api from '$lib/api.js'; | ||||
|     import { account, logged_in } from '$lib/stores/account.js'; | ||||
|     import { server } from '$lib/client/server.js'; | ||||
|     import { app } from '$lib/client/app.js'; | ||||
|     import { play_sound } from '$lib/sound.js'; | ||||
|     import { getTimeline } from '$lib/timeline.js'; | ||||
|     import { getNotifications } from '$lib/notifications.js'; | ||||
|  | @ -59,7 +62,22 @@ | |||
| 
 | ||||
|     async function log_out() { | ||||
|         if (!confirm("This will log you out. Are you sure?")) return; | ||||
|         await get(client).logout(); | ||||
|          | ||||
|         const res = await api.revokeToken( | ||||
|             get(server).host, | ||||
|             get(app).id, | ||||
|             get(app).secret, | ||||
|             get(app).token | ||||
|         ); | ||||
| 
 | ||||
|         if (!res.ok) | ||||
|             console.warn("Token revocation failed! Dumping data anyways"); | ||||
| 
 | ||||
|         logged_in.set(false); | ||||
|         account.set(false); | ||||
|         app.set(false); | ||||
|         server.set(false); | ||||
| 
 | ||||
|         goto("/"); | ||||
|     } | ||||
| </script> | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue