File tree Expand file tree Collapse file tree 2 files changed +28
-14
lines changed
web/speakerbob/src/components Expand file tree Collapse file tree 2 files changed +28
-14
lines changed Original file line number Diff line number Diff line change @@ -176,6 +176,7 @@ func (s *Service) callback(w http.ResponseWriter, r *http.Request) {
176176 Expires : newToken .ExpiresAt ,
177177 Secure : true ,
178178 Path : "/" ,
179+ HttpOnly : true ,
179180 SameSite : http .SameSiteStrictMode ,
180181 }
181182
@@ -344,18 +345,21 @@ func (s *Service) listProviders(w http.ResponseWriter, _ *http.Request) {
344345
345346// Logout
346347func (s * Service ) logout (w http.ResponseWriter , r * http.Request ) {
348+ token := s .TokenProvider .FromRequest (r )
349+
350+ if token != nil && s .TokenProvider .Delete (token ) != nil {
351+ w .WriteHeader (http .StatusInternalServerError )
352+ }
353+
347354 cookie := & http.Cookie {
348355 Name : cookieName ,
356+ Secure : true ,
357+ Path : "/" ,
358+ HttpOnly : true ,
349359 SameSite : http .SameSiteStrictMode ,
350360 }
351361
352362 http .SetCookie (w , cookie )
353363
354- token := s .TokenProvider .FromRequest (r )
355-
356- if token != nil && s .TokenProvider .Delete (token ) != nil {
357- w .WriteHeader (http .StatusInternalServerError )
358- }
359-
360364 w .WriteHeader (http .StatusNoContent )
361365}
Original file line number Diff line number Diff line change 1010 <v-list-item-title >Preferences</v-list-item-title >
1111 </v-list-item >
1212 <v-spacer />
13- <v-list-item @click =" goto(' logout') " >
13+ <v-list-item @click =" logout" >
1414 <v-list-item-title >Logout</v-list-item-title >
1515 </v-list-item >
1616 </v-list >
2020<script lang="ts">
2121import { Vue , Component } from ' vue-property-decorator'
2222import { UserPreferences } from ' @/definitions/userpreferences'
23+ import axios from ' axios'
2324
2425@Component
2526export default class UserMenu extends Vue {
2627 public disabled = false
2728 public user: UserPreferences = new UserPreferences ();
2829
2930 public async created () {
30- const resp = await this .$auth .get (' /user/preferences/' )
31-
32- if (resp .status === 404 ) {
33- this .disabled = true
34- return
31+ try {
32+ const resp = await axios .get (' /auth/user/preferences/' )
33+ this .user = resp .data
34+ } catch (e ) {
35+ if (axios .isAxiosError (e )) {
36+ if (!! e .response && (e .response .status === 404 || e .response .status === 401 )) {
37+ this .disabled = true
38+ return
39+ }
40+ }
41+ throw e
3542 }
36-
37- this .user = resp .data
3843 }
3944
4045 private async goto (path : string ) {
4146 await this .$router .push (path )
4247 }
48+
49+ private logout () {
50+ this .disabled = true
51+ this .goto (' logout' )
52+ }
4353}
4454 </script >
You can’t perform that action at this time.
0 commit comments