Fix: Remove legacy otp from login and show the right device id.
This commit is contained in:
parent
eb2f783b9e
commit
a1a1c10dff
|
@ -82,11 +82,10 @@ export class AuthService {
|
||||||
return this.currentUserSubject.value;
|
return this.currentUserSubject.value;
|
||||||
}
|
}
|
||||||
|
|
||||||
login(username: string, password: string, otp: string) {
|
login(username: string, password: string) {
|
||||||
const formData: FormData = new FormData();
|
const formData: FormData = new FormData();
|
||||||
formData.append('username', username);
|
formData.append('username', username);
|
||||||
formData.append('password', password);
|
formData.append('password', password);
|
||||||
formData.append('otp', otp);
|
|
||||||
formData.append('grant_type', 'password');
|
formData.append('grant_type', 'password');
|
||||||
return this.http
|
return this.http
|
||||||
.post<{ access_token: string; token_type: string }>(loginUrl, formData)
|
.post<{ access_token: string; token_type: string }>(loginUrl, formData)
|
||||||
|
|
|
@ -26,31 +26,7 @@
|
||||||
</mat-form-field>
|
</mat-form-field>
|
||||||
</div>
|
</div>
|
||||||
<mat-divider></mat-divider>
|
<mat-divider></mat-divider>
|
||||||
<h2 *ngIf="showOtp">Client ID: {{ clientId }}</h2>
|
<h2 *ngIf="unregisteredDevice">Sorry, device {{ deviceName }} is not enabled.</h2>
|
||||||
<div
|
|
||||||
fxLayout="row"
|
|
||||||
fxLayout.lt-md="column"
|
|
||||||
fxLayoutGap="20px"
|
|
||||||
fxLayoutGap.lt-md="0px"
|
|
||||||
*ngIf="showOtp"
|
|
||||||
>
|
|
||||||
<mat-form-field fxFlex>
|
|
||||||
<mat-label>Otp</mat-label>
|
|
||||||
<input matInput placeholder="Otp" formControlName="otp" />
|
|
||||||
</mat-form-field>
|
|
||||||
</div>
|
|
||||||
<div
|
|
||||||
fxLayout="row"
|
|
||||||
fxLayout.lt-md="column"
|
|
||||||
fxLayoutGap="20px"
|
|
||||||
fxLayoutGap.lt-md="0px"
|
|
||||||
*ngIf="showOtp"
|
|
||||||
>
|
|
||||||
<mat-form-field fxFlex>
|
|
||||||
<mat-label>Client Name</mat-label>
|
|
||||||
<input matInput placeholder="Client Name" formControlName="clientName" />
|
|
||||||
</mat-form-field>
|
|
||||||
</div>
|
|
||||||
</form>
|
</form>
|
||||||
</mat-card-content>
|
</mat-card-content>
|
||||||
<mat-card-actions>
|
<mat-card-actions>
|
||||||
|
|
|
@ -15,8 +15,8 @@ export class LoginComponent implements OnInit, AfterViewInit {
|
||||||
@ViewChild('nameElement', { static: true }) nameElement?: ElementRef;
|
@ViewChild('nameElement', { static: true }) nameElement?: ElementRef;
|
||||||
form: FormGroup;
|
form: FormGroup;
|
||||||
hide: boolean;
|
hide: boolean;
|
||||||
showOtp: boolean;
|
unregisteredDevice: boolean;
|
||||||
clientId: string;
|
deviceName: string;
|
||||||
private returnUrl: string;
|
private returnUrl: string;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
|
@ -28,8 +28,8 @@ export class LoginComponent implements OnInit, AfterViewInit {
|
||||||
private fb: FormBuilder,
|
private fb: FormBuilder,
|
||||||
) {
|
) {
|
||||||
this.hide = true;
|
this.hide = true;
|
||||||
this.showOtp = false;
|
this.unregisteredDevice = false;
|
||||||
this.clientId = '';
|
this.deviceName = '';
|
||||||
this.returnUrl = '';
|
this.returnUrl = '';
|
||||||
|
|
||||||
// Create form
|
// Create form
|
||||||
|
@ -56,9 +56,8 @@ export class LoginComponent implements OnInit, AfterViewInit {
|
||||||
const formModel = this.form.value;
|
const formModel = this.form.value;
|
||||||
const { username } = formModel;
|
const { username } = formModel;
|
||||||
const { password } = formModel;
|
const { password } = formModel;
|
||||||
const { otp } = formModel;
|
|
||||||
this.auth
|
this.auth
|
||||||
.login(username, password, otp)
|
.login(username, password)
|
||||||
// .pipe(first())
|
// .pipe(first())
|
||||||
.subscribe(
|
.subscribe(
|
||||||
() => {
|
() => {
|
||||||
|
@ -66,8 +65,8 @@ export class LoginComponent implements OnInit, AfterViewInit {
|
||||||
},
|
},
|
||||||
(error) => {
|
(error) => {
|
||||||
if (error.status === 401 && error.error.detail === 'Device is not registered') {
|
if (error.status === 401 && error.error.detail === 'Device is not registered') {
|
||||||
this.showOtp = true;
|
this.unregisteredDevice = true;
|
||||||
this.clientId = this.cs.getCookie('device_id');
|
this.deviceName = this.cs.getCookie('device');
|
||||||
}
|
}
|
||||||
this.toaster.show('Error', error.error.detail);
|
this.toaster.show('Error', error.error.detail);
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in New Issue