Auth errors were not showing up as they were swallowed up by the auth interceptor.
Once caught, the device name was not being shown as it was triggering an expression changed after detection error.
This commit is contained in:
1 parent
68ab90ec48
commit
abc1b36721
2 files changed
+19
-19
No files matched your search
@@ -1,4 +1,4 @@
|
||||
import { AfterViewInit, Component, ElementRef, OnInit, ViewChild } from '@angular/core';
|
||||
import { AfterViewInit, ChangeDetectorRef, Component, ElementRef, OnInit, ViewChild } from '@angular/core';
|
||||
import { FormControl, FormGroup, Validators, ReactiveFormsModule } from '@angular/forms';
|
||||
import { MatButtonModule } from '@angular/material/button';
|
||||
import { MatCardModule } from '@angular/material/card';
|
||||
@@ -44,6 +44,7 @@ export class LoginComponent implements OnInit, AfterViewInit {
|
||||
private router: Router,
|
||||
private toaster: ToasterService,
|
||||
private cs: CookieService,
|
||||
private cd: ChangeDetectorRef,
|
||||
) {
|
||||
this.hide = true;
|
||||
this.unregisteredDevice = false;
|
||||
@@ -73,20 +74,19 @@ export class LoginComponent implements OnInit, AfterViewInit {
|
||||
const formModel = this.form.value;
|
||||
const username = formModel.username ?? '';
|
||||
const password = formModel.password ?? '';
|
||||
this.auth
|
||||
.login(username.trim(), password.trim())
|
||||
// .pipe(first())
|
||||
.subscribe({
|
||||
next: () => {
|
||||
this.router.navigateByUrl(this.returnUrl);
|
||||
},
|
||||
error: (error) => {
|
||||
if (error.status === 401 && error.detail === 'Device is not registered') {
|
||||
this.unregisteredDevice = true;
|
||||
this.deviceName = this.cs.getCookie('device');
|
||||
}
|
||||
this.toaster.show('Error', error.detail);
|
||||
},
|
||||
});
|
||||
this.auth.login(username.trim(), password.trim()).subscribe({
|
||||
next: () => {
|
||||
this.router.navigateByUrl(this.returnUrl);
|
||||
},
|
||||
error: (error) => {
|
||||
if (error.status === 401 && error.error.detail === 'Device is not registered') {
|
||||
this.unregisteredDevice = true;
|
||||
this.deviceName = this.cs.getCookie('device');
|
||||
console.log(this.deviceName, this.unregisteredDevice);
|
||||
this.cd.detectChanges();
|
||||
}
|
||||
this.toaster.show('Error', error.error.detail);
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user