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