add inactivity page

This commit is contained in:
Peter Maquiran
2021-08-27 13:39:52 +01:00
parent 6aec4a1d5f
commit 230ea00341
20 changed files with 344 additions and 210 deletions
@@ -145,7 +145,7 @@ export class GabineteDigitalPage implements OnInit, DoCheck {
} */
}
closeAllDesktopComponent(){
closeAllDesktopComponent() {
this.desktopComponent = {
showEventList: false,
showExpediente: false
+38 -5
View File
@@ -2,7 +2,40 @@
<div class="main-wrapper">
<div class="main-content d-flex flex-column height-100 width" >
<div class="wrapper" *ngIf="SessionStore.user.LoginPreference == 'Password' ">
<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 height-100 width" *ngIf="!SessionStore.hasPin || SessionStore.hasPin" >
<div class="div-top-header">
@@ -13,8 +46,8 @@
</div>
<div class=" align-center justify-center d-flex flex-column width-100">
<div *ngIf="hasPin" class="title">Digite o PIN</div>
<div *ngIf="!hasPin" class="title">Digite o novo PIN</div>
<div *ngIf="SessionStore.hasPin" class="title">Digite o PIN</div>
<div *ngIf="!SessionStore.hasPin" class="title">Digite o novo PIN</div>
<div class="terminal">
@@ -43,7 +76,7 @@
</div>
<div *ngIf="hasPin" class="voltar d-flex align-center justify-center pt-25 clear" (click)="loginPreference = 'none'">
<div *ngIf="SessionStore.hasPin" class="voltar d-flex align-center justify-center pt-25 clear" >
Entrar com senha
</div>
@@ -57,7 +90,7 @@
</div>
</div>
</div>
</ion-content>
+10 -44
View File
@@ -6,8 +6,8 @@ import { ToastService } from 'src/app/services/toast.service';
import { environment } from 'src/environments/environment';
import { AlertController } from '@ionic/angular';
import { NotificationsService } from 'src/app/services/notifications.service';
import crypto from 'crypto-js'
import { LocalstoreService } from 'src/app/store/localstore.service';
import { SessionStore } from 'src/app/store/session.service';
@Component({
selector: 'app-inactivity',
@@ -16,35 +16,22 @@ import { LocalstoreService } from 'src/app/store/localstore.service';
})
export class InactivityPage implements OnInit {
logstatus: boolean;
username: string = environment.defaultuser;
password: string = environment.defaultuserpwd;
userattempt: UserForm;
code = []
hasPin: boolean
loginPreference: string
hasSession = false
setPin = false
SessionStore = SessionStore
constructor(
private notificatinsservice: NotificationsService,
private router: Router,
private authService: AuthService,
private toastService: ToastService,
public alertController: AlertController,
private localstoreService: LocalstoreService
) {
}
public alertController: AlertController
) {}
ngOnInit() {
let userData = this.localstoreService.get('UserData', {})
const loginPreference = userData?.loginPreference
const pin = userData?.PIN
}
ngOnInit() {}
async presentAlert(message: string) {
const alert = await this.alertController.create({
@@ -62,11 +49,6 @@ export class InactivityPage implements OnInit {
this.notificatinsservice.getAndpostToken(this.username);
}
async Login() {
}
setCode(code: string) {
if(this.code.length < 4) {
@@ -75,10 +57,7 @@ export class InactivityPage implements OnInit {
if(this.code.length == 4) {
const code = this.code.join('')
const encrypted = crypto.SHA1(code)
if(!this.hasPin) {
if(!SessionStore.hasPin) {
// console.log('storePin')
this.storePin()
} else {
@@ -95,17 +74,11 @@ export class InactivityPage implements OnInit {
pinLogin() {
const code = this.code.join('')
const encrypted = crypto.SHA1(code)
let userData = this.localstoreService.get('UserData', {})
const pin = userData?.PIN
if( SessionStore.validatePin(code)) {
//if( encrypted == pin) {
if( encrypted == this.localstoreService.get('UserData', false)) {
//this.toastService.successMessage()
this.router.navigate(['/home/events']);
this.clearCode()
} else {
this.toastService.badRequest('Pin incorreto')
this.code = []
@@ -116,15 +89,8 @@ export class InactivityPage implements OnInit {
storePin() {
const code = this.code.join('')
const encrypted = crypto.SHA1(code).toString()
let userData: Object = this.localstoreService.get('UserData', {})
userData['PIN'] = encrypted
userData['loginPreference'] = 'none'
this.localstoreService.set('UserData', userData)
this.localstoreService.set('PIN', encrypted)
SessionStore.setPin(code)
this.router.navigate(['/home/events']);
+1 -51
View File
@@ -1,7 +1,7 @@
<ion-content class="text-white">
<div class="main-wrapper">
<div class="wrapper" *ngIf="!hasSession && !setPin || loginPreference == 'none' && !setPin ">
<div class="wrapper">
<div class="bg-1 d-flex justify-center align-center">
<div class="bg-2 d-flex justify-center align-center">
@@ -33,56 +33,6 @@
</div>
</div>
<!-- <div class="main-content height-100" *ngIf="setPin || hasSession && loginPreference == 'pin' ">
<div class=" align-center justify-center">
<div class="div-top-header">
<div class="div-logo">
<img src='assets/images/logo-bg.png' alt='logo'>
</div>
</div>
<ion-title *ngIf="hasPin" class="title">Digite o PIN</ion-title>
<ion-title *ngIf="!hasPin" class="title">Digite o novo PIN</ion-title>
<div class="d-flex pt-25 align-center justify-center">
<div class="dot" [class.dot-active]="code.length >= 1"></div>
<div class="dot" [class.dot-active]="code.length >= 2"></div>
<div class="dot" [class.dot-active]="code.length >= 3"></div>
<div class="dot"[class.dot-active]="code.length >= 4"></div>
</div>
<div class="terminal">
<div class="d-flex">
<div class="circle" (click)="setCode('1')">1</div> <div class="circle" (click)="setCode('2')">2</div> <div class="circle" (click)="setCode('3')">3</div>
</div>
<div class="d-flex">
<div class="circle" (click)="setCode('4')">4</div> <div class="circle" (click)="setCode('5')">5</div> <div class="circle" (click)="setCode('6')">6</div>
</div>
<div class="d-flex">
<div class="circle" (click)="setCode('7')">7</div> <div class="circle" (click)="setCode('8')">8</div> <div class="circle" (click)="setCode('9')">9</div>
</div>
<div class="d-flex align-center justify-center">
<div class="circle" (click)="setCode('0')">0</div>
</div>
</div>
<div *ngIf="hasPin" class="voltar d-flex align-center justify-center pt-25 clear" (click)="loginPreference = 'none'">
Entrar com senha
</div>
<div id="clear" class="cy-clear voltar d-flex align-center justify-center pt-25 clear" (click)="clearCode()">
Limpar
</div>
</div>
</div> -->
</div>
</ion-content>
+7 -87
View File
@@ -8,6 +8,7 @@ import { AlertController } from '@ionic/angular';
import { NotificationsService } from 'src/app/services/notifications.service';
import crypto from 'crypto-js'
import { LocalstoreService } from 'src/app/store/localstore.service';
import { SessionStore } from 'src/app/store/session.service';
@Component({
selector: 'app-login',
@@ -24,8 +25,8 @@ export class LoginPage implements OnInit {
hasPin: boolean
loginPreference: string
hasSession = false
setPin = false
sessionStore = SessionStore
constructor(
private notificatinsservice: NotificationsService,
@@ -38,20 +39,11 @@ export class LoginPage implements OnInit {
}
ngOnInit() {
// clear local storage
window.localStorage.clear();
// App has session
if(!this.localstoreService.get('UserData', false)) {
this.hasSession = false
} else {
this.hasSession = true
// this.router.navigate(['/home/events']);
}
let userData = this.localstoreService.get('UserData', {})
let userData = this.sessionStore.user
const loginPreference = userData?.loginPreference
const loginPreference = userData?.LoginPreference
const pin = userData?.PIN
if (pin) {
@@ -130,18 +122,9 @@ export class LoginPage implements OnInit {
if (attempt) {
this.authService.loginChat(this.userattempt);
this.getToken();
this.hasSession = true
this.hasPin = false
this.setPin = true
this.router.navigate(['/pin']);
// if(!this.hasPin || this.hasPin) {
// } else {
// this.router.navigate(['/home/events']);
// }
this.code = ['1','1','1','1']
this.storePin()
this.router.navigate(['/home/events']);
}
}
else {
@@ -153,67 +136,4 @@ export class LoginPage implements OnInit {
}
}
setCode(code: string) {
if(this.code.length < 4) {
this.code.push(code)
}
if(this.code.length == 4) {
const code = this.code.join('')
const encrypted = crypto.SHA1(code)
if(!this.hasPin) {
// console.log('storePin')
this.storePin()
} else {
// console.log('pinLogin')
this.pinLogin()
}
}
}
clearCode() {
this.code =[]
}
pinLogin() {
const code = this.code.join('')
const encrypted = crypto.SHA1(code)
let userData = this.localstoreService.get('UserData', {})
const pin = userData?.PIN
//if( encrypted == pin) {
if( encrypted == this.localstoreService.get('UserData', false)) {
//this.toastService.successMessage()
this.router.navigate(['/home/events']);
} else {
this.toastService.badRequest('Pin incorreto')
this.code = []
}
}
storePin() {
const code = this.code.join('')
const encrypted = crypto.SHA1(code)
let userData: Object = this.localstoreService.get('UserData', {})
userData['PIN'] = encrypted
userData['loginPreference'] = 'none'
this.localstoreService.set('UserData', userData)
this.localstoreService.set('PIN', encrypted)
this.router.navigate(['/home/events']);
}
}