mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-18 20:47:54 +00:00
63 lines
1.3 KiB
TypeScript
63 lines
1.3 KiB
TypeScript
import { Component, OnInit } from '@angular/core';
|
|
import { AnimationController, ModalController } from '@ionic/angular';
|
|
import crypto from 'crypto-js'
|
|
import { ToastService } from 'src/app/services/toast.service';
|
|
import { LocalstoreService } from 'src/app/store/localstore.service';
|
|
@Component({
|
|
selector: 'app-pin',
|
|
templateUrl: './pin.page.html',
|
|
styleUrls: ['./pin.page.scss'],
|
|
})
|
|
export class PinPage implements OnInit {
|
|
|
|
code = []
|
|
constructor( private modalController: ModalController,
|
|
private animationController: AnimationController,
|
|
private toastService: ToastService,
|
|
private localstoreService: LocalstoreService) { }
|
|
|
|
ngOnInit() {
|
|
}
|
|
|
|
setCode(code: string) {
|
|
if(this.code.length < 4) {
|
|
this.code.push(code)
|
|
}
|
|
|
|
if(this.code.length == 4) {
|
|
this.save()
|
|
}
|
|
|
|
}
|
|
|
|
clearCode() {
|
|
this.code =[]
|
|
}
|
|
|
|
close() {
|
|
this.modalController.dismiss();
|
|
}
|
|
|
|
async save() {
|
|
if(this.code.length == 4) {
|
|
|
|
this.close()
|
|
//this.toastService.successMessage()
|
|
|
|
const code = this.code.join('')
|
|
const encrypted = crypto.SHA1(code)
|
|
|
|
localStorage.setItem('PIN', encrypted)
|
|
this.localstoreService.set('PIN', encrypted)
|
|
|
|
} else {
|
|
this.toastService.badRequest()
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
} |