-accouting Wep
All checks were successful
Build Docker Image / Build Docker Image (push) Successful in 8m54s
All checks were successful
Build Docker Image / Build Docker Image (push) Successful in 8m54s
This commit is contained in:
@@ -14,7 +14,7 @@ import { finalize } from 'rxjs/operators';
|
||||
export class LoginContentComponent implements OnInit {
|
||||
@ViewChild(LoginForgotComponent) loginForgotComponent!: LoginForgotComponent;
|
||||
@ViewChild(LoginPageComponent) loginPageComponent!: LoginPageComponent;
|
||||
mode: 'forgot-password' | 'default' = 'default';
|
||||
mode: 'forgot-password' | 'register' | 'default' = 'default';
|
||||
|
||||
constructor(
|
||||
private generalService: GeneralService,
|
||||
@@ -27,6 +27,8 @@ export class LoginContentComponent implements OnInit {
|
||||
|
||||
if (param === 'forgot-password') {
|
||||
this.mode = 'forgot-password';
|
||||
}else if(param === 'register'){
|
||||
this.mode = 'register';
|
||||
} else {
|
||||
// this.router.navigate(['/login']); // This can cause navigation loops
|
||||
this.mode = 'default';
|
||||
@@ -57,6 +59,7 @@ export class LoginContentComponent implements OnInit {
|
||||
if (result.code === '200' && result.data?.token) {
|
||||
this.generalService.trowApi(result);
|
||||
localStorage.setItem('access_token', result.data.token);
|
||||
localStorage.setItem('username', result.data.usrthinam);
|
||||
this.router.navigate(['main/dashboard']);
|
||||
} else {
|
||||
const errorMessage = result.message_th || result.message || 'Sign-in failed.';
|
||||
@@ -76,6 +79,28 @@ export class LoginContentComponent implements OnInit {
|
||||
});
|
||||
}
|
||||
|
||||
onRegisterSubmit(value: any){
|
||||
const uri = '/api/login/register';
|
||||
const request = {
|
||||
username: value.username,
|
||||
password: value.password,
|
||||
email: value.email
|
||||
};
|
||||
|
||||
this.generalService.postRequest(uri, request).subscribe({
|
||||
next: (result: any) => {
|
||||
if (result.code === '200') { }
|
||||
else {
|
||||
this.generalService.trowApi(result);
|
||||
}
|
||||
},
|
||||
error: (error: any) => {
|
||||
this.generalService.trowApi(error);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
onOtpSendSubmit(value: any){
|
||||
let uri = '/api/login/otp/send';
|
||||
|
||||
Reference in New Issue
Block a user