Skip to content

Commit 11dd5d3

Browse files
committed
Add logout method for login.gov
1 parent 93c707c commit 11dd5d3

3 files changed

Lines changed: 19 additions & 3 deletions

File tree

src/app/header/header.component.ts

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -104,10 +104,20 @@ export class HeaderComponent implements OnInit {
104104
onLogout() {
105105
const u = new Currentuser('', '', '', '', '', '');
106106
this.userService.saveUser(u);
107-
this.authGuard.isLogin = false;
107+
const loginMethod = localStorage.getItem('loginMethod');
108108
this.app.isLogin = false;
109-
this.authService.logout();
110-
this.router.navigateByUrl('auth').then();
109+
this.authGuard.isLogin = false;
110+
111+
const logoutURL = this.authService.logout();
112+
113+
// TODO: Implement when only Login.gov is used
114+
if (loginMethod === 'login.gov') {
115+
window.location.href = logoutURL;
116+
}
117+
else {
118+
this.router.navigateByUrl('auth').then();
119+
}
120+
111121
}
112122

113123
/**

src/app/shared/services/auth.service.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ export class AuthService {
1919

2020
private userUrl = environment.SERVER_URL + '/auth/user';
2121
private loginUrl = environment.SERVER_URL + '/auth/login';
22+
private logoutUrl = environment.SERVER_URL + '/logout';
23+
2224
private tokenUrl = environment.SERVER_URL + '/auth/tokenCheck';
2325
private resetUrl = environment.SERVER_URL + '/auth/resetPassword';
2426
private authUrl = environment.SERVER_URL + '/auth';
@@ -69,6 +71,8 @@ export class AuthService {
6971
logout() {
7072
localStorage.removeItem('token');
7173
localStorage.clear();
74+
75+
return this.logoutUrl
7276
}
7377

7478
/**

src/index.html

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,8 @@
6868
if (data.position !== undefined) localStorage.setItem('position', data.position);
6969
if (data.token !== undefined) localStorage.setItem('token', data.token);
7070
if (data.userRole !== undefined) localStorage.setItem('userRole', data.userRole);
71+
if (data.loginMethod !== undefined) localStorage.setItem('loginMethod', data.loginMethod);
72+
7173
window.location = '/';
7274
}
7375
return false;

0 commit comments

Comments
 (0)