Skip to content

Commit

Permalink
Merge pull request #109 from GSA/feature/80_login_gov
Browse files Browse the repository at this point in the history
Add logout method for login.gov
  • Loading branch information
BuckinghamAJ authored Mar 1, 2024
2 parents e71e9dc + 11dd5d3 commit e0c0c42
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 3 deletions.
16 changes: 13 additions & 3 deletions src/app/header/header.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,10 +104,20 @@ export class HeaderComponent implements OnInit {
onLogout() {
const u = new Currentuser('', '', '', '', '', '');
this.userService.saveUser(u);
this.authGuard.isLogin = false;
const loginMethod = localStorage.getItem('loginMethod');
this.app.isLogin = false;
this.authService.logout();
this.router.navigateByUrl('auth').then();
this.authGuard.isLogin = false;

const logoutURL = this.authService.logout();

// TODO: Implement when only Login.gov is used
if (loginMethod === 'login.gov') {
window.location.href = logoutURL;
}
else {
this.router.navigateByUrl('auth').then();
}

}

/**
Expand Down
4 changes: 4 additions & 0 deletions src/app/shared/services/auth.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ export class AuthService {

private userUrl = environment.SERVER_URL + '/auth/user';
private loginUrl = environment.SERVER_URL + '/auth/login';
private logoutUrl = environment.SERVER_URL + '/logout';

private tokenUrl = environment.SERVER_URL + '/auth/tokenCheck';
private resetUrl = environment.SERVER_URL + '/auth/resetPassword';
private authUrl = environment.SERVER_URL + '/auth';
Expand Down Expand Up @@ -69,6 +71,8 @@ export class AuthService {
logout() {
localStorage.removeItem('token');
localStorage.clear();

return this.logoutUrl
}

/**
Expand Down
2 changes: 2 additions & 0 deletions src/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@
if (data.position !== undefined) localStorage.setItem('position', data.position);
if (data.token !== undefined) localStorage.setItem('token', data.token);
if (data.userRole !== undefined) localStorage.setItem('userRole', data.userRole);
if (data.loginMethod !== undefined) localStorage.setItem('loginMethod', data.loginMethod);

window.location = '/';
}
return false;
Expand Down

0 comments on commit e0c0c42

Please sign in to comment.