-
Notifications
You must be signed in to change notification settings - Fork 5
Login & Logout Buttons
Stan Silvert edited this page Jan 28, 2018
·
1 revision
keycloak-schematic adds the KeycloakService, which makes it easy to create login and logout buttons.
First, inject the KeycloakService into your component.
import { KeycloakService } from './keycloak-service/keycloak.service';
.
.
constructor(private kcSvc: KeycloakService) {}<button [hidden]="!kcSvc.authenticated()" (click)="kcSvc.logout('http://localhost:4200/')">Log Out</button>
<button [hidden]="kcSvc.authenticated()" (click)="kcSvc.login()">Log In</button>- Note that logout() has an optional parameter telling where to redirect when logout is completed.