mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-19 21:06:06 +00:00
Improve login
This commit is contained in:
@@ -1,37 +1,6 @@
|
||||
<ion-content class="text-white">
|
||||
|
||||
<div class="main-wrapper">
|
||||
<div class="wrapper" *ngIf="SessionStore.user.LoginPreference == 'Password' && SessionStore.hasPin || SessionStore.user.LoginPreference == null && SessionStore.hasPin || SessionStore.user.LoginPreference == 'None' && SessionStore.hasPin || enterWithPassword">
|
||||
|
||||
<div class="bg-1 d-flex justify-center align-center">
|
||||
<div class="bg-2 d-flex justify-center align-center">
|
||||
<div class="bg-3 d-flex justify-center align-center">
|
||||
<div class="bg-4 d-flex justify-center align-center">
|
||||
<div class="div-logo">
|
||||
<img src='assets/images/fullLogo.png' alt='logo'>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<h3 class="center text-white">Inicie a sessão</h3>
|
||||
<form class="form">
|
||||
<p class="form-label text-white">Email</p>
|
||||
<ion-item class="form-input">
|
||||
<ion-input type="text" [(ngModel)]="username" name="input-username"></ion-input>
|
||||
</ion-item>
|
||||
<p class="form-label text-white">Palavra-passe</p>
|
||||
<ion-item class="form-input">
|
||||
<ion-input (keyup.enter)="Login()" type="password" [(ngModel)]="password" name="input-password" ></ion-input>
|
||||
</ion-item>
|
||||
<div class="d-flex pt-25">
|
||||
<button class="btn-ok btn-login" fill="clear" expand="block" shape="round" (click)="Login()">Iniciar</button>
|
||||
</div>
|
||||
</form>
|
||||
<div class="msg-bottom d-flex">
|
||||
<p class="msg-bottom-p">Uma iniciativa do Gabinete do Presidente da República</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="main-content d-flex flex-column width" *ngIf="!SessionStore.hasPin || SessionStore.hasPin && SessionStore.user.LoginPreference == 'Pin' && !enterWithPassword " >
|
||||
|
||||
|
||||
@@ -110,7 +110,7 @@ export class InactivityPage implements OnInit {
|
||||
domainName: environment.domain,
|
||||
BasicAuthKey: ""
|
||||
}
|
||||
let attempt = await this.authService.login(this.userattempt, false)
|
||||
let attempt = await this.authService.login(this.userattempt, {saveSession: false})
|
||||
|
||||
if (attempt) {
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@ import { SessionStore } from 'src/app/store/session.service';
|
||||
export class LoginPage implements OnInit {
|
||||
|
||||
logstatus: boolean;
|
||||
username: string = environment.defaultuser;
|
||||
username: string = SessionStore.user.Email || environment.defaultuser;
|
||||
password: string = environment.defaultuserpwd;
|
||||
userattempt: UserForm;
|
||||
code = []
|
||||
@@ -35,26 +35,7 @@ export class LoginPage implements OnInit {
|
||||
) {
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
|
||||
let userData = this.sessionStore.user
|
||||
|
||||
const loginPreference = userData?.LoginPreference
|
||||
const pin = userData?.PIN
|
||||
|
||||
if (pin) {
|
||||
this.hasPin = true
|
||||
} else {
|
||||
this.hasPin = false
|
||||
}
|
||||
|
||||
if (loginPreference) {
|
||||
this.loginPreference = loginPreference
|
||||
} else {
|
||||
this.loginPreference = ''
|
||||
}
|
||||
|
||||
}
|
||||
ngOnInit() {}
|
||||
|
||||
//Function to validade the login inputs
|
||||
validateUsername() {
|
||||
@@ -95,13 +76,23 @@ export class LoginPage implements OnInit {
|
||||
domainName: environment.domain,
|
||||
BasicAuthKey: ""
|
||||
}
|
||||
let attempt = await this.authService.login(this.userattempt)
|
||||
|
||||
let attempt = await this.authService.login(this.userattempt, {saveSession: false})
|
||||
|
||||
if (attempt) {
|
||||
await this.authService.loginChat(this.userattempt);
|
||||
await this.getToken();
|
||||
|
||||
this.router.navigate(['/pin']);
|
||||
if (attempt.UserId == SessionStore.user.UserId) {
|
||||
await this.authService.SetSession(attempt, this.userattempt);
|
||||
this.authService.loginChat(this.userattempt);
|
||||
this.getToken();
|
||||
SessionStore.setInativity(true)
|
||||
this.goback()
|
||||
} else {
|
||||
SessionStore.delete()
|
||||
window.localStorage.clear();
|
||||
await this.authService.SetSession(attempt, this.userattempt);
|
||||
this.router.navigate(['/pin']);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -114,4 +105,15 @@ export class LoginPage implements OnInit {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
goback() {
|
||||
const pathName = SessionStore.user.UrlBeforeInactivity
|
||||
if(pathName) {
|
||||
this.router.navigate([pathName]);
|
||||
} else {
|
||||
this.router.navigate(['/home/events']);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user