This commit is contained in:
tiago.kayaya
2022-02-08 16:37:32 +01:00
parent 0c01cb1ebc
commit b169ff5687
4 changed files with 18 additions and 18 deletions
+2 -2
View File
@@ -29,8 +29,8 @@ export class AuthGuard implements CanActivate {
this.router.navigate(['/']); this.router.navigate(['/']);
return false return false
} else { } else {
this.authService.loginChat(SessionStore.user) this.authService.loginChat();
return true return true;
} }
} }
+10 -10
View File
@@ -36,11 +36,11 @@ export class InactivityPage implements OnInit {
loop = false loop = false
ngOnInit() { ngOnInit() {
// window.addEventListener('resize', (event) => { // window.addEventListener('resize', (event) => {
// if(this.router.url != '/login') return false // if(this.router.url != '/login') return false
// if(this.loop == false) { // if(this.loop == false) {
// this.loop = true // this.loop = true
// this.runloop() // this.runloop()
@@ -54,7 +54,7 @@ export class InactivityPage implements OnInit {
// const containerHeight = 651 // const containerHeight = 651
// let circleHeight = document.querySelector('.circle')['offsetHeight'] // let circleHeight = document.querySelector('.circle')['offsetHeight']
// let circleWidth = document.querySelector('.circle')['offsetWidth'] // let circleWidth = document.querySelector('.circle')['offsetWidth']
// console.log(window.innerHeight, ' < ', containerHeight) // console.log(window.innerHeight, ' < ', containerHeight)
// console.log(circleHeight) // console.log(circleHeight)
@@ -64,7 +64,7 @@ export class InactivityPage implements OnInit {
// e['style']['width'] = (circleWidth -1 )+'px' // e['style']['width'] = (circleWidth -1 )+'px'
// }) // })
// if( window.innerHeight< containerHeight) { // if( window.innerHeight< containerHeight) {
// setTimeout(()=>{ // setTimeout(()=>{
// this.runloop() // this.runloop()
@@ -114,14 +114,14 @@ export class InactivityPage implements OnInit {
let attempt = await this.authService.login(this.userattempt, {saveSession: false}) let attempt = await this.authService.login(this.userattempt, {saveSession: false})
if (attempt) { if (attempt) {
// if current attemp is equal to the current user // if current attemp is equal to the current user
if (attempt.UserId == SessionStore.user.UserId) { if (attempt.UserId == SessionStore.user.UserId) {
await this.authService.SetSession(attempt, this.userattempt); await this.authService.SetSession(attempt, this.userattempt);
this.authService.loginChat(this.userattempt); this.authService.loginChat();
this.getToken(); this.getToken();
SessionStore.setInativity(true) SessionStore.setInativity(true)
this.goback() this.goback()
} else { } else {
SessionStore.delete() SessionStore.delete()
@@ -174,10 +174,10 @@ export class InactivityPage implements OnInit {
const code = this.code.join('') const code = this.code.join('')
if( SessionStore.validatePin(code)) { if( SessionStore.validatePin(code)) {
SessionStore.setInativity(true) SessionStore.setInativity(true)
this.goback() this.goback()
setTimeout(()=>{ setTimeout(()=>{
this.clearCode() this.clearCode()
}, 1000) }, 1000)
@@ -196,7 +196,7 @@ export class InactivityPage implements OnInit {
} else { } else {
this.router.navigate(['/home/events'], {replaceUrl: true}); this.router.navigate(['/home/events'], {replaceUrl: true});
} }
} }
storePin() { storePin() {
+2 -2
View File
@@ -102,7 +102,7 @@ export class LoginPage implements OnInit {
if (attempt) { if (attempt) {
if (attempt.UserId == SessionStore.user.UserId) { if (attempt.UserId == SessionStore.user.UserId) {
await this.authService.SetSession(attempt, this.userattempt); await this.authService.SetSession(attempt, this.userattempt);
await this.authService.loginChat(this.userattempt); await this.authService.loginChat();
this.getToken(); this.getToken();
SessionStore.setInativity(true); SessionStore.setInativity(true);
@@ -116,7 +116,7 @@ export class LoginPage implements OnInit {
await this.authService.SetSession(attempt, this.userattempt); await this.authService.SetSession(attempt, this.userattempt);
this.changeProfileService.run() this.changeProfileService.run()
await this.authService.loginChat(this.userattempt); await this.authService.loginChat();
this.getToken(); this.getToken();
this.router.navigateByUrl('/pin', { replaceUrl: true }); this.router.navigateByUrl('/pin', { replaceUrl: true });
} }
+4 -4
View File
@@ -109,7 +109,7 @@ export class AuthService {
//Login to rocketChat server2 //Login to rocketChat server2
//user: UserForm //user: UserForm
async loginChat(user: any) { async loginChat() {
const expirationMinutes = 60; const expirationMinutes = 60;
let date = new Date().getTime(); let date = new Date().getTime();
@@ -136,12 +136,12 @@ export class AuthService {
this.presentAlert('Network error'); this.presentAlert('Network error');
} }
this.autoLoginChat(expirationDate.getTime() - date, user); this.autoLoginChat(expirationDate.getTime() - date);
} }
async autoLoginChat(expirationDate:number, user:any){ async autoLoginChat(expirationDate:number){
setTimeout(()=>{ setTimeout(()=>{
this.loginChat(user); this.loginChat();
}, expirationDate) }, expirationDate)
} }