-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implemented login method selection in UI.
List of allowed login methods is specified via runtime config
- Loading branch information
1 parent
80bbf47
commit cf20181
Showing
26 changed files
with
655 additions
and
109 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,10 @@ | ||
{ | ||
"apiServerGqlUrl": "http://localhost:8080/graphql", | ||
"featureFlags": { | ||
"enableLogin": true, | ||
"enableLogout": true | ||
"enableLogout": true, | ||
"loginMethods": [ | ||
"password", | ||
"oauth_github" | ||
] | ||
} | ||
} |
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,30 @@ | ||
import { NavigationService } from "src/app/services/navigation.service"; | ||
import { Injectable } from "@angular/core"; | ||
import { CanLoad, Route } from "@angular/router"; | ||
import { ActivatedRouteSnapshot, CanActivate, RouterStateSnapshot } from "@angular/router"; | ||
import { AppConfigService } from "src/app/app-config.service"; | ||
import ProjectLinks from "src/app/project-links"; | ||
import { LoggedUserService } from "../logged-user.service"; | ||
|
||
@Injectable({ | ||
providedIn: "root", | ||
}) | ||
export class LoginGuard implements CanLoad { | ||
export class LoginGuard implements CanActivate { | ||
constructor( | ||
private navigationService: NavigationService, | ||
private appConfigService: AppConfigService, | ||
private loggedUserService: LoggedUserService, | ||
) {} | ||
|
||
public canLoad(route: Route): boolean { | ||
if (route.path === ProjectLinks.URL_LOGIN && !this.canLogin()) { | ||
public canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): boolean { | ||
// URLs start from / | ||
if (state.url.slice(1) === ProjectLinks.URL_LOGIN && !this.canLogin()) { | ||
this.navigationService.navigateToHome(); | ||
return false; | ||
} | ||
return true; | ||
} | ||
|
||
private canLogin(): boolean { | ||
return this.appConfigService.featureFlags.enableLogin && !this.loggedUserService.isAuthenticated; | ||
return this.appConfigService.featureFlags.loginMethods.length > 0 && !this.loggedUserService.isAuthenticated; | ||
} | ||
} |
Oops, something went wrong.