[update]
This commit is contained in:
@@ -1,10 +1,11 @@
|
||||
import { Component, OnInit } from '@angular/core';
|
||||
import { ActivatedRoute, Router } from '@angular/router';
|
||||
import { Router } from '@angular/router';
|
||||
import { AppService } from '../../app.service';
|
||||
import { environment } from "../../../environments/environment";
|
||||
import { AuthService } from 'src/app/core/service/auth/auth.service';
|
||||
import { catchError, lastValueFrom, tap, throwError } from 'rxjs';
|
||||
import { lastValueFrom } from 'rxjs';
|
||||
import { EAction, EText } from 'src/app/@config/app';
|
||||
import { CathayAuthService } from 'src/app/core/service/auth/cathay-auth.service';
|
||||
|
||||
|
||||
@Component({
|
||||
@@ -13,15 +14,19 @@ import { EAction, EText } from 'src/app/@config/app';
|
||||
styles: []
|
||||
})
|
||||
export class LoginComponent implements OnInit {
|
||||
// apiUrl: string = API.login;
|
||||
dataForm: any = {};
|
||||
cathayForm: any = {
|
||||
mobileDeviceId : "1234",
|
||||
userName: 'admin',
|
||||
password: 'P@ssword1'
|
||||
};
|
||||
isLoading = false;
|
||||
|
||||
constructor(
|
||||
private router: Router,
|
||||
private appService: AppService,
|
||||
private route: ActivatedRoute,
|
||||
private authService: AuthService
|
||||
private authService: AuthService,
|
||||
private cathayAuthService: CathayAuthService
|
||||
) {
|
||||
}
|
||||
|
||||
@@ -38,8 +43,11 @@ export class LoginComponent implements OnInit {
|
||||
async onSubmit(form: any) {
|
||||
if (!form.valid) return false;
|
||||
try {
|
||||
const result = await lastValueFrom(this.authService.login(this.dataForm));
|
||||
this.appService.setAuth(result);
|
||||
// const result = await lastValueFrom(this.authService.login(this.dataForm));
|
||||
const cathayResult = await lastValueFrom(this.cathayAuthService.login(this.cathayForm))
|
||||
// this.cathayAuthService.login(this.cathayForm).subscribe(res => console.log(res))
|
||||
console.log(cathayResult)
|
||||
this.appService.setAuth(cathayResult);
|
||||
return this.router.navigate(['/pages']);
|
||||
} catch (err) {
|
||||
return this.appService.message(EAction.ERROR, EText.NO_DATA);
|
||||
|
||||
Reference in New Issue
Block a user