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
+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']);