From a1a1c10dff4c3e3ddc1306c860ecea87bc94d1c8 Mon Sep 17 00:00:00 2001 From: tanshu Date: Sat, 26 Jun 2021 09:14:36 +0530 Subject: [PATCH] Fix: Remove legacy otp from login and show the right device id. --- bookie/src/app/auth/auth.service.ts | 3 +-- .../src/app/auth/login/login.component.html | 26 +------------------ bookie/src/app/auth/login/login.component.ts | 15 +++++------ 3 files changed, 9 insertions(+), 35 deletions(-) diff --git a/bookie/src/app/auth/auth.service.ts b/bookie/src/app/auth/auth.service.ts index c658f60..deabf6a 100644 --- a/bookie/src/app/auth/auth.service.ts +++ b/bookie/src/app/auth/auth.service.ts @@ -82,11 +82,10 @@ export class AuthService { return this.currentUserSubject.value; } - login(username: string, password: string, otp: string) { + login(username: string, password: string) { const formData: FormData = new FormData(); formData.append('username', username); formData.append('password', password); - formData.append('otp', otp); formData.append('grant_type', 'password'); return this.http .post<{ access_token: string; token_type: string }>(loginUrl, formData) diff --git a/bookie/src/app/auth/login/login.component.html b/bookie/src/app/auth/login/login.component.html index 1a2e4d0..7461577 100644 --- a/bookie/src/app/auth/login/login.component.html +++ b/bookie/src/app/auth/login/login.component.html @@ -26,31 +26,7 @@ -

Client ID: {{ clientId }}

-
- - Otp - - -
-
- - Client Name - - -
+

Sorry, device {{ deviceName }} is not enabled.

diff --git a/bookie/src/app/auth/login/login.component.ts b/bookie/src/app/auth/login/login.component.ts index feeda0b..74d9901 100644 --- a/bookie/src/app/auth/login/login.component.ts +++ b/bookie/src/app/auth/login/login.component.ts @@ -15,8 +15,8 @@ export class LoginComponent implements OnInit, AfterViewInit { @ViewChild('nameElement', { static: true }) nameElement?: ElementRef; form: FormGroup; hide: boolean; - showOtp: boolean; - clientId: string; + unregisteredDevice: boolean; + deviceName: string; private returnUrl: string; constructor( @@ -28,8 +28,8 @@ export class LoginComponent implements OnInit, AfterViewInit { private fb: FormBuilder, ) { this.hide = true; - this.showOtp = false; - this.clientId = ''; + this.unregisteredDevice = false; + this.deviceName = ''; this.returnUrl = ''; // Create form @@ -56,9 +56,8 @@ export class LoginComponent implements OnInit, AfterViewInit { const formModel = this.form.value; const { username } = formModel; const { password } = formModel; - const { otp } = formModel; this.auth - .login(username, password, otp) + .login(username, password) // .pipe(first()) .subscribe( () => { @@ -66,8 +65,8 @@ export class LoginComponent implements OnInit, AfterViewInit { }, (error) => { if (error.status === 401 && error.error.detail === 'Device is not registered') { - this.showOtp = true; - this.clientId = this.cs.getCookie('device_id'); + this.unregisteredDevice = true; + this.deviceName = this.cs.getCookie('device'); } this.toaster.show('Error', error.error.detail); },