Skip to content
Snippets Groups Projects
Commit b9d7d688 authored by Hamza HRAMCHI's avatar Hamza HRAMCHI
Browse files

FEAT #15550 TIME 0:05 handle enter keyboard key when log

parent 219c8734
No related branches found
No related tags found
No related merge requests found
......@@ -424,6 +424,7 @@
"workflowTemplateAdded": "Workflow template added",
"by": "by",
"the": "the",
"passwordRuleUpdated": "Updated password rules"
"passwordRuleUpdated": "Updated password rules",
"requiredLoginPassword": "Please complete all fields"
}
}
\ No newline at end of file
......@@ -422,6 +422,7 @@
"workflowTemplateAdded": "Modèle de circuit ajouté",
"by": "par",
"the": "le",
"passwordRuleUpdated": "Règles de mot de passe mises à jour"
"passwordRuleUpdated": "Règles de mot de passe mises à jour",
"requiredLoginPassword": "Veuillez renseigner tous les champs"
}
}
......@@ -5,11 +5,11 @@
<form (ngSubmit)="onSubmit()" [formGroup]="loginForm">
<ion-item>
<ion-label position="floating">{{'lang.login' | translate}}</ion-label>
<ion-input formControlName="login" type="text"></ion-input>
<ion-input formControlName="login" type="text" (keyup.enter)="onSubmit()"></ion-input>
</ion-item>
<ion-item>
<ion-label position="floating">{{'lang.password' | translate}}</ion-label>
<ion-input name="password" matInput type="password" formControlName="password"></ion-input>
<ion-input name="password" matInput type="password" formControlName="password" (keyup.enter)="onSubmit()"></ion-input>
</ion-item>
<a routerLink="/forgot-password" *ngIf="authService.authMode === 'default'"
class="forgot-password">{{'lang.forgotPassword' | translate}}</a>
......
......@@ -75,31 +75,37 @@ export class LoginComponent implements OnInit, AfterViewInit {
message: this.translate.instant('lang.connexion'),
});
await loading.present();
this.http.post('../rest/authenticate', { 'login': this.loginForm.get('login').value, 'password': this.loginForm.get('password').value }, { observe: 'response' })
.pipe(
tap((data: any) => {
this.loading = false;
this.showForm = false;
this.authService.saveTokens(data.headers.get('Token'), data.headers.get('Refresh-Token'));
this.authService.setUser({});
this.router.navigate(['/home']);
loading.dismiss();
}),
catchError((err: any) => {
this.loading = false;
if (err.status === 401) {
this.notificationService.error('lang.wrongLoginPassword');
if(!this.loginForm.invalid ) {
this.http.post('../rest/authenticate', { 'login': this.loginForm.get('login').value, 'password': this.loginForm.get('password').value }, { observe: 'response' })
.pipe(
tap((data: any) => {
this.loading = false;
this.showForm = false;
this.authService.saveTokens(data.headers.get('Token'), data.headers.get('Refresh-Token'));
this.authService.setUser({});
this.router.navigate(['/home']);
loading.dismiss();
} else {
this.notificationService.handleErrors(err);
}
return of(false);
})
)
.subscribe();
}),
catchError((err: any) => {
this.loading = false;
if (err.status === 401) {
this.notificationService.error('lang.wrongLoginPassword');
loading.dismiss();
} else {
this.notificationService.handleErrors(err);
}
return of(false);
})
)
.subscribe();
} else {
loading.dismiss();
this.notificationService.error('lang.requiredLoginPassword')
}
}
initConnection() {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment