[update]
This commit is contained in:
@@ -1,9 +1,10 @@
|
||||
import { Component, OnInit } from '@angular/core';
|
||||
import { ActivatedRoute, Router } from '@angular/router';
|
||||
import { AppService } from '../../app.service';
|
||||
import { lastValueFrom } from "rxjs";
|
||||
import { EAction, EText } from "../../@config/app";
|
||||
import { environment } from "../../../environments/environment";
|
||||
import { AuthService } from 'src/app/core/service/auth/auth.service';
|
||||
import { catchError, lastValueFrom, tap, throwError } from 'rxjs';
|
||||
import { EAction, EText } from 'src/app/@config/app';
|
||||
|
||||
|
||||
@Component({
|
||||
@@ -19,7 +20,8 @@ export class LoginComponent implements OnInit {
|
||||
constructor(
|
||||
private router: Router,
|
||||
private appService: AppService,
|
||||
private route: ActivatedRoute
|
||||
private route: ActivatedRoute,
|
||||
private authService: AuthService
|
||||
) {
|
||||
}
|
||||
|
||||
@@ -28,30 +30,19 @@ export class LoginComponent implements OnInit {
|
||||
if (!environment.production) {
|
||||
this.dataForm = {
|
||||
username: 'admin',
|
||||
password: 'password@1',
|
||||
password: 'admin',
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
async onSubmit(form: any) {
|
||||
if (!form.valid) return false;
|
||||
const dataForm = {
|
||||
username: this.dataForm.username,
|
||||
password: this.dataForm.password,
|
||||
userType: 'ADMIN'
|
||||
};
|
||||
|
||||
|
||||
try {
|
||||
// console.log(this.apiUrl)
|
||||
// const result = await lastValueFrom(this.appService.post(this.apiUrl, dataForm));
|
||||
// this.appService.setAuth(result.data);
|
||||
// this.appService.setToken(result.accessToken);
|
||||
await lastValueFrom(this.authService.login(this.dataForm));
|
||||
return this.router.navigate(['/pages']);
|
||||
} catch (err) {
|
||||
return this.appService.message(EAction.ERROR, EText.NO_DATA);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user