mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-19 21:06:06 +00:00
Improve local storage
This commit is contained in:
@@ -7,6 +7,7 @@ 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';
|
||||
|
||||
@Component({
|
||||
selector: 'app-login',
|
||||
@@ -31,22 +32,23 @@ export class LoginPage implements OnInit {
|
||||
private router: Router,
|
||||
private authService: AuthService,
|
||||
private toastService: ToastService,
|
||||
public alertController: AlertController
|
||||
public alertController: AlertController,
|
||||
private localstoreService: LocalstoreService
|
||||
) {
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
|
||||
// App has session
|
||||
if(!localStorage.getItem('UserData')) {
|
||||
if(!this.localstoreService.get('UserData', false)) {
|
||||
this.hasSession = false
|
||||
} else {
|
||||
this.hasSession = true
|
||||
// this.router.navigate(['/home/events']);
|
||||
}
|
||||
|
||||
let userData = JSON.parse(localStorage.getItem('UserData')) || {}
|
||||
|
||||
let userData = this.localstoreService.get('UserData', {})
|
||||
|
||||
const loginPreference = userData?.loginPreference
|
||||
const pin = userData?.PIN
|
||||
|
||||
@@ -176,13 +178,13 @@ export class LoginPage implements OnInit {
|
||||
|
||||
const code = this.code.join('')
|
||||
const encrypted = crypto.SHA1(code)
|
||||
|
||||
let userData = JSON.parse(localStorage.getItem('UserData')) || {}
|
||||
|
||||
let userData = this.localstoreService.get('UserData', {})
|
||||
const pin = userData?.PIN
|
||||
|
||||
//if( encrypted == pin) {
|
||||
|
||||
if( encrypted == localStorage.getItem('PIN')) {
|
||||
if( encrypted == this.localstoreService.get('UserData', false)) {
|
||||
|
||||
//this.toastService.successMessage()
|
||||
this.router.navigate(['/home/events']);
|
||||
@@ -197,15 +199,16 @@ export class LoginPage implements OnInit {
|
||||
|
||||
const code = this.code.join('')
|
||||
const encrypted = crypto.SHA1(code)
|
||||
let userData: Object = JSON.parse(localStorage.getItem('UserData')) || {}
|
||||
let userData: Object = this.localstoreService.get('UserData', {})
|
||||
|
||||
userData['PIN'] = encrypted
|
||||
userData['loginPreference'] = 'none'
|
||||
|
||||
|
||||
localStorage.setItem('UserData', JSON.stringify(userData) )
|
||||
|
||||
this.localstoreService.set('UserData', userData)
|
||||
|
||||
localStorage.setItem('PIN', encrypted)
|
||||
|
||||
this.localstoreService.set('PIN', encrypted)
|
||||
|
||||
//
|
||||
if(window['cy']) {
|
||||
|
||||
Reference in New Issue
Block a user