diff --git a/src/app/pages/login/login.page.html b/src/app/pages/login/login.page.html
index 83f620dee..875fd4c2e 100644
--- a/src/app/pages/login/login.page.html
+++ b/src/app/pages/login/login.page.html
@@ -26,7 +26,9 @@
- Digite o PIN novo
+ Digite o PIN
+ Digite o novo PIN
+
= 1">
= 2">
diff --git a/src/app/pages/login/login.page.scss b/src/app/pages/login/login.page.scss
index b0073b636..c767ce0e8 100644
--- a/src/app/pages/login/login.page.scss
+++ b/src/app/pages/login/login.page.scss
@@ -126,7 +126,7 @@ ion-content{
-o-border-radius: 50px;
}
-.main-content{
+.main-content {
background-color: white;
text-align: center;
align-items: center;
diff --git a/src/app/pages/login/login.page.ts b/src/app/pages/login/login.page.ts
index 43ceadb5f..37214ff0e 100644
--- a/src/app/pages/login/login.page.ts
+++ b/src/app/pages/login/login.page.ts
@@ -33,6 +33,7 @@ export class LoginPage implements OnInit {
password: string = environment.defaultuserpwd;
userattempt: UserForm;
code = []
+ setPint = false
pin = localStorage.getItem('PIN') != null
@@ -47,11 +48,9 @@ export class LoginPage implements OnInit {
public alertController: AlertController,
private modalController: ModalController
//private fcm: FCM
- ) { }
+ ) { }
- ngOnInit() {
-
- }
+ ngOnInit() {}
//Function to validade the login inputs
validateInput() {
@@ -94,9 +93,7 @@ export class LoginPage implements OnInit {
}
async Login() {
- /* try { */
- //Go to our home in home/feed.
- //this.router.navigate(['/home/events']);
+
if (this.validateInput()) {
this.userattempt = {
username: this.username,
@@ -108,7 +105,13 @@ export class LoginPage implements OnInit {
this.loginRocketChat();
//this.getToken();
- this.router.navigate(['/home/events']);
+ if(!this.pin) {
+ this.setPint = true
+ this.pin = true
+ } else {
+ this.router.navigate(['/home/events']);
+ }
+
}
else {
//this.toastService.presentToast('Não foi possível fazer login"');
@@ -127,7 +130,15 @@ export class LoginPage implements OnInit {
}
if(this.code.length == 4) {
- this.pinLogin()
+
+ const code = this.code.join('')
+ const encrypted = crypto.SHA1(code)
+
+ if(this.setPint) {
+ this.storePin()
+ } else {
+ this.pinLogin()
+ }
}
}
@@ -151,6 +162,16 @@ export class LoginPage implements OnInit {
}
+ storePin() {
+ const code = this.code.join('')
+ const encrypted = crypto.SHA1(code)
+
+ localStorage.setItem('PIN', encrypted)
+
+ this.router.navigate(['/home/events']);
+
+ }
+
async successMessage(message?: string) {
const modal = await this.modalController.create({