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-header>
<mat-card-content> <mat-card-content>
<mat-error *ngIf="missingToken"> <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-error>
<mat-form-field> <mat-form-field>
<input matInput placeholder="{{'username' | i18n}}" formControlName="username" <input matInput placeholder="{{'username' | i18n}}" formControlName="username"

View File

@ -24,6 +24,7 @@ export class RegisterComponent implements OnInit {
form: FormGroup; form: FormGroup;
missingToken: boolean; missingToken: boolean;
lockedToken: boolean;
success: boolean; success: boolean;
working: boolean; working: boolean;
items = []; items = [];
@ -95,6 +96,7 @@ export class RegisterComponent implements OnInit {
register() { register() {
this.missingToken = false; this.missingToken = false;
this.lockedToken = false;
if(this.form.valid && !this.working) { if(this.form.valid && !this.working) {
this.working = true; this.working = true;
let pgpOption = { let pgpOption = {
@ -136,6 +138,8 @@ export class RegisterComponent implements OnInit {
this.working = false; this.working = false;
if(error.status == 401) { if(error.status == 401) {
this.missingToken = true; this.missingToken = true;
} if(error.status == 423) {
this.lockedToken = true;
} else if(error.status == 409) { } else if(error.status == 409) {
let errors = {}; let errors = {};
for(let code of error.error) { for(let code of error.error) {

View File

@ -54,7 +54,7 @@
<a *ngIf="!auth.authenticated" routerLink="/register" mat-raised-button color="accent"> <a *ngIf="!auth.authenticated" routerLink="/register" mat-raised-button color="accent">
<mat-icon>how_to_reg</mat-icon> {{'register' | i18n}} <mat-icon>how_to_reg</mat-icon> {{'register' | i18n}}
</a> </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"> color="primary">
<mat-icon>login</mat-icon> {{'login' | i18n}} <mat-icon>login</mat-icon> {{'login' | i18n}}
</a> </a>