register token validation
This commit is contained in:
parent
112edb2889
commit
c4f1d5151b
@ -5,7 +5,17 @@
|
||||
</mat-card-header>
|
||||
<mat-card-content>
|
||||
<mat-error *ngIf="missingToken">
|
||||
<a routerLink="/tokens">{{'register.token.missing' | i18n}}</a>
|
||||
{{'register.token.missing' | i18n}}
|
||||
|
||||
<a routerLink="/tokens" mat-raised-button color="warn">{{'register.token.missing.action' |
|
||||
i18n}}</a>
|
||||
|
||||
</mat-error>
|
||||
<mat-error *ngIf="lockedToken">
|
||||
{{'register.token.locked' | i18n}}
|
||||
|
||||
<a routerLink="/login" [queryParams]="{ target:'/tokens' }" mat-raised-button
|
||||
color="warn">{{'register.token.locked.action' | i18n}}</a>
|
||||
</mat-error>
|
||||
<mat-form-field>
|
||||
<input matInput placeholder="{{'username' | i18n}}" formControlName="username"
|
||||
|
@ -24,6 +24,7 @@ export class RegisterComponent implements OnInit {
|
||||
|
||||
form: FormGroup;
|
||||
missingToken: boolean;
|
||||
lockedToken: boolean;
|
||||
success: boolean;
|
||||
working: boolean;
|
||||
items = [];
|
||||
@ -95,6 +96,7 @@ export class RegisterComponent implements OnInit {
|
||||
|
||||
register() {
|
||||
this.missingToken = false;
|
||||
this.lockedToken = false;
|
||||
if(this.form.valid && !this.working) {
|
||||
this.working = true;
|
||||
let pgpOption = {
|
||||
@ -136,6 +138,8 @@ export class RegisterComponent implements OnInit {
|
||||
this.working = false;
|
||||
if(error.status == 401) {
|
||||
this.missingToken = true;
|
||||
} if(error.status == 423) {
|
||||
this.lockedToken = true;
|
||||
} else if(error.status == 409) {
|
||||
let errors = {};
|
||||
for(let code of error.error) {
|
||||
|
@ -54,7 +54,7 @@
|
||||
<a *ngIf="!auth.authenticated" routerLink="/register" mat-raised-button color="accent">
|
||||
<mat-icon>how_to_reg</mat-icon> {{'register' | i18n}}
|
||||
</a>
|
||||
<a *ngIf="!auth.authenticated" routerLink="/login" [queryParams]="{ target:'tokens' }" mat-raised-button
|
||||
<a *ngIf="!auth.authenticated" routerLink="/login" [queryParams]="{ target:'/tokens' }" mat-raised-button
|
||||
color="primary">
|
||||
<mat-icon>login</mat-icon> {{'login' | i18n}}
|
||||
</a>
|
||||
|
Loading…
Reference in New Issue
Block a user