-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add app config 'requireAccessCode' for users to lock access to online…
… surveys
- Loading branch information
esurface
committed
May 31, 2024
1 parent
a92d271
commit 69fce19
Showing
9 changed files
with
79 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 12 additions & 5 deletions
17
online-survey-app/src/app/core/auth/_guards/login-guard.service.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,26 @@ | ||
import { Injectable } from '@angular/core'; | ||
import { ActivatedRouteSnapshot, CanActivate, Router, RouterStateSnapshot } from '@angular/router'; | ||
import { AuthenticationService } from '../_services/authentication.service'; | ||
import { AppConfigService } from 'src/app/shared/_services/app-config.service'; | ||
|
||
@Injectable() | ||
export class LoginGuard implements CanActivate { | ||
|
||
constructor( | ||
private router: Router, | ||
private authenticationService: AuthenticationService | ||
private authenticationService: AuthenticationService, | ||
private appConfigService: AppConfigService | ||
) { } | ||
async canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot) { | ||
if (await this.authenticationService.isLoggedIn()) { | ||
return true; | ||
const config = await this.appConfigService.getAppConfig(); | ||
if (config['requireAccessCode'] === 'true') { | ||
if (await this.authenticationService.isLoggedIn()) { | ||
return true; | ||
} | ||
this.router.navigate(['survey-login'], { queryParams: { returnUrl: state.url } }); | ||
return false; | ||
} | ||
this.router.navigate(['survey-login'], { queryParams: { returnUrl: state.url } }); | ||
return false; | ||
|
||
return true; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters