This repository was archived by the owner on May 13, 2024. It is now read-only.
File tree 4 files changed +18
-4
lines changed
4 files changed +18
-4
lines changed Original file line number Diff line number Diff line change @@ -16,10 +16,23 @@ import OIDCJSONAPIAdapter from "ember-simple-auth-oidc/adapters/oidc-json-api-ad
16
16
*/
17
17
export default class ApplicationAdapter extends OIDCJSONAPIAdapter {
18
18
@service session ;
19
+ @service router ;
19
20
20
21
namespace = "api/v1" ;
21
22
22
23
get headers ( ) {
23
24
return { ...this . session . headers } ;
24
25
}
26
+
27
+ handleResponse ( status , ...args ) {
28
+ if ( status === 401 ) {
29
+ if ( this . session . isAuthenticated ) {
30
+ this . session . invalidate ( ) ;
31
+ } else {
32
+ this . router . transitionTo ( "login" ) ;
33
+ }
34
+ }
35
+
36
+ return super . handleResponse ( status , ...args ) ;
37
+ }
25
38
}
Original file line number Diff line number Diff line change 65
65
</LinkTo >
66
66
</li >
67
67
<li class =" nav-top-list-item" >
68
- <a href =" #" data-test-logout {{ on " click" (optional this.on-logout )}} >
68
+ <a href =" #" data-test-logout {{ on " click" (optional @ onLogout )}} >
69
69
<FaIcon @icon =" power-off" @prefix =" fas" />
70
70
Logout
71
71
</a >
Original file line number Diff line number Diff line change @@ -30,10 +30,11 @@ export default class ProtectedController extends Controller {
30
30
* @public
31
31
*/
32
32
@action
33
- invalidateSession ( ) {
33
+ async invalidateSession ( ) {
34
34
this . autostartTour . done = [ ] ;
35
35
36
- this . session . invalidate ( ) ;
36
+ await this . session . invalidate ( ) ;
37
+
37
38
this . router . transitionTo ( "login" ) ;
38
39
}
39
40
Original file line number Diff line number Diff line change 1
1
<main class =" page-main" >
2
2
{{ #if this.loading }} <span class =" loader" ></span >{{ /if }}
3
3
<div class =" page-content page-content--scroll" >
4
- <SyTopnav @on-logout ={{ this.invalidateSession }} />
4
+ <SyTopnav @onLogout ={{ this.invalidateSession }} />
5
5
6
6
{{ outlet }}
7
7
</div >
You can’t perform that action at this time.
0 commit comments