register token validation

This commit is contained in:
_Bastler 2021-11-11 19:24:11 +01:00
parent 112edb2889
commit c4f1d5151b
3 changed files with 16 additions and 2 deletions

View File

@ -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"

View File

@ -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) {

View File

@ -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>