[feat] - add authen and display transaction data
This commit is contained in:
@@ -6,6 +6,7 @@ import { AuthService } from 'src/app/core/service/auth/auth.service';
|
||||
import { lastValueFrom } from 'rxjs';
|
||||
import { EAction, EText } from 'src/app/@config/app';
|
||||
import { CathayAuthService } from 'src/app/core/service/auth/cathay-auth.service';
|
||||
import { ROLE_ADMIN } from 'src/app/@config/menus';
|
||||
|
||||
|
||||
@Component({
|
||||
@@ -32,21 +33,25 @@ export class LoginComponent implements OnInit {
|
||||
|
||||
ngOnInit() {
|
||||
|
||||
if (!environment.production) {
|
||||
this.dataForm = {
|
||||
username: 'admin',
|
||||
password: 'admin',
|
||||
}
|
||||
}
|
||||
// if (!environment.production) {
|
||||
// this.dataForm = {
|
||||
// username: 'admin',
|
||||
// password: 'admin',
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
||||
async onSubmit(form: any) {
|
||||
if (!form.valid) return false;
|
||||
try {
|
||||
const result = await lastValueFrom(this.authService.login(this.dataForm));
|
||||
const cathayResult: any = await lastValueFrom(this.cathayAuthService.login(this.cathayForm));
|
||||
// const result = await lastValueFrom(this.authService.login(this.dataForm));
|
||||
let cathayResult: any = await lastValueFrom(this.cathayAuthService.login(this.cathayForm));
|
||||
cathayResult = {
|
||||
...cathayResult,
|
||||
isAdmin: cathayResult.token.userName == ROLE_ADMIN ? true : false
|
||||
}
|
||||
this.appService.setToken(cathayResult.token.token)
|
||||
this.appService.setAuth(result);
|
||||
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