File
Metadata
selector |
ab-login |
templateUrl |
./login.component.html |
Index
Properties
|
|
Methods
|
|
Inputs
|
|
translateService
|
Type: any
|
|
Methods
Public
openLoginModal
|
openLoginModal()
|
|
|
Public
options
|
options: any
|
Type : any
|
|
import {Component, Input} from '@angular/core';
import {Router} from '@angular/router';
import {AuthenticationService} from '../../services/authentication/authentication.service';
import {ConfigService} from '../../services/config.service';
@Component({
selector: 'ab-login',
templateUrl: './login.component.html'
})
export class LoginComponent {
@Input() translateService: any;
public options: any;
constructor(private router: Router, public config: ConfigService, private authService: AuthenticationService) {
}
ngOnInit() {
this.options = {
authenticated: false,
context: this,
// accessTokenId: 'app:localhost:3000:accesToken',
// refreshTokenId: 'app:localhost:3000:refreshToken',
// refreshTokenUrl: `http://localhost:3000/refresh`,
// loginUrl: `http://localhost:3000/login`,
loginHandler: this.login,
logoutHandler: this.logout,
// <!--[translateService]="options.translateService"-->
// nameRegex]:"option.nameRegex";
// passwordRegex:"option.passwordRegex"-->
// nameLabel:"option.nameLabel"
// <!--[passwordLabel]:"'PASSWORD'"-->
// <!--[submitLabel]:"'LOGIN'"-->
// <!--[nameError]:"'REQUIRED'"-->
// <!--[passwordError]:"'PASSWORD REQUIRED'"-->
// <!--[submitError]:"option.submitError"-->
// <!--(login)="option.loginHandler.call(options.context,$event)">-->
};
Object.keys(this.config.get('authConfig')).forEach((k, i) => {
this.options[k] = this.config.get('authConfig')[k];
});
this.authService.init(this.options);
}
public openLoginModal() {
// console.log('todo: openLoginModal');
this.config.services.appService.openLoginModal();
}
public login() {
console.log(localStorage)
let credentials = {};
this.authService
.login()
.subscribe(() => this.router.navigateByUrl('/'));
}
public logout() {
console.log(localStorage)
}
}
<ab-login-button [authenticated]="config.get('authenticated')" (click)="openLoginModal()"></ab-login-button>
<div class="padding margin-top">
<div class="pull-right">
<p>
Public area!
</p>
<button (click)="login()">
Login auth
</button>
</div>
<!--<ab-login-form class="card panel container padding"-->
<!--(login)="options.loginHandler.call(options.context,$event)">-->
<!--<h5 class="text-center">{{ config.services.translateService.instant('LOGIN') }}</h5>-->
<!--<!–<h5 class="text-center">{{ 'LOGIN' | translate }}</h5>–>-->
<!--</ab-login-form>-->
<!--<ab-login-form class="card panel container padding"-->
<!--[translateService]="config.services.translateService"-->
<!--(login)="options.loginHandler.call(options.context,$event)">-->
<!--<h5 class="text-center">{{ config.services.translateService.instant('LOGIN') }}</h5>-->
<!--<!–<h5 class="text-center">{{ 'LOGIN' | translate }}</h5>–>-->
<!--</ab-login-form>-->
</div>
<!--<ab-login-form *ngIf="!options.authenticated"-->
<!--[translateService]="options.translateService"-->
<!--[nameRegex]="options.nameRegex"-->
<!--[passwordRegex]="options.passwordRegex"-->
<!--[nameLabel]="options.nameLabel"-->
<!--[passwordLabel]="'PASSWORD'"-->
<!--[submitLabel]="'LOGIN'"-->
<!--[nameError]="'REQUIRED'"-->
<!--[passwordError]="'PASSWORD REQUIRED'"-->
<!--[submitError]="options.submitError"-->
<!--(login)="options.loginHandler.call(options.context,$event)">-->
<!--</ab-login-form>-->
<!--<form *ngIf="options.authenticated">-->
<!--<button type="submit" (click)="options.logoutHandler($event)" class="btn btn-default">{{ 'LOGOUT' | translate }}</button>-->
<!--</form>-->
Legend
Html element with directive