Skip to content

Commit

Permalink
Authorization error message
Browse files Browse the repository at this point in the history
  • Loading branch information
newmanw committed Jul 5, 2024
1 parent 3baf3fd commit 7c00d97
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
1 change: 1 addition & 0 deletions web-app/src/app/authentication/authorize.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
<mat-form-field appearance="fill">
<mat-label>Access Code</mat-label>
<input matInput placeholder="Access Code" type="deviceId" [formControl]="deviceId" required>
<mat-error *ngIf="deviceId.hasError('invalid')">Invalid access code</mat-error>
</mat-form-field>
</div>

Expand Down
4 changes: 3 additions & 1 deletion web-app/src/app/authentication/authorize.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { LocalStorageService } from '../http/local-storage.service';
})
export class AuthorizeComponent {
token: string
deviceId = new FormControl('', [Validators.required]);
deviceId = new FormControl('', [Validators.required])

constructor(
private router: Router,
Expand All @@ -22,6 +22,7 @@ export class AuthorizeComponent {
}

authorize(): void {
this.deviceId.setErrors(null)
this.userService.authorize(this.token, this.deviceId.value).subscribe({
next: (response) => {
// TODO set token event"
Expand All @@ -31,6 +32,7 @@ export class AuthorizeComponent {
},
error: () => {
console.log('Error authentication')
this.deviceId.setErrors({ invalid: true})
// TODO show error message
}
})
Expand Down

0 comments on commit 7c00d97

Please sign in to comment.