diff --git a/src/app/shared/popover/opts-expediente/opts-expediente.page.html b/src/app/shared/popover/opts-expediente/opts-expediente.page.html index c10130669..74d594800 100644 --- a/src/app/shared/popover/opts-expediente/opts-expediente.page.html +++ b/src/app/shared/popover/opts-expediente/opts-expediente.page.html @@ -22,7 +22,7 @@ - +
From 14d521a30c756cdfb1212a301816974121247d95 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Eudes=20In=C3=A1cio?= Date: Sat, 16 Apr 2022 19:23:44 +0100 Subject: [PATCH 4/4] Login user parametrization --- src/app/models/user.model.ts | 14 ++++++++++++++ src/app/pages/login/login.page.ts | 13 +++++++------ src/app/services/auth.service.ts | 23 ++++++++++++++++------- src/app/services/chat.service.ts | 5 +++-- src/environments/environment.prod.ts | 9 ++++++--- 5 files changed, 46 insertions(+), 18 deletions(-) diff --git a/src/app/models/user.model.ts b/src/app/models/user.model.ts index 24f420637..a0e0855e8 100644 --- a/src/app/models/user.model.ts +++ b/src/app/models/user.model.ts @@ -10,6 +10,13 @@ export class LoginUserRespose { BasicAuthKey: string; UserId: number; Authorization: string; + ChatData: { + status: string, + data: { + userId: string, + authToken: string + } + } Email: string FullName: string OwnerCalendars: { @@ -38,6 +45,13 @@ export class UserSession { BasicAuthKey: string; UserId: number; Authorization: string; + ChatData: { + status: string, + data: { + userId: string, + authToken: string + } + } Email: string FullName: string ManagerName: string diff --git a/src/app/pages/login/login.page.ts b/src/app/pages/login/login.page.ts index 751c3cb26..8cfd9d7d7 100644 --- a/src/app/pages/login/login.page.ts +++ b/src/app/pages/login/login.page.ts @@ -112,10 +112,10 @@ export class LoginPage implements OnInit { console.log(this.p.userPermission(this.p.permissionList.Chat.access)); - if(this.p.userPermission(this.p.permissionList.Chat.access)){ - await this.authService.loginChat(); + /* if(this.p.userPermission(this.p.permissionList.Chat.access)){*/ + await this.authService.loginChat(attempt.ChatData.data); await this.authService.loginToChatWs(); - } + //} this.getToken(); SessionStore.setInativity(true); @@ -132,10 +132,11 @@ export class LoginPage implements OnInit { this.changeProfileService.run(); - if(this.p.userPermission(this.p.permissionList.Chat.access)){ - await this.authService.loginChat(); + console.log(attempt.ChatData) + /* if(this.p.userPermission(this.p.permissionList.Chat.access)){*/ + await this.authService.loginChat(attempt.ChatData.data); await this.authService.loginToChatWs(); - } + //} this.getToken(); diff --git a/src/app/services/auth.service.ts b/src/app/services/auth.service.ts index 3cebb8fc3..933a94fc1 100644 --- a/src/app/services/auth.service.ts +++ b/src/app/services/auth.service.ts @@ -94,6 +94,10 @@ export class AuthService { SetSession(response: LoginUserRespose, user:UserForm) { const session: UserSession = Object.assign(SessionStore.user, response) + console.log('SETSESSION', response, user) + console.log('SETSESSION 2', session) + + if (response) { if( session.RoleID == 100000014) { session.Profile = 'PR' @@ -141,9 +145,13 @@ export class AuthService { //Login to rocketChat server2 //user: UserForm - async loginChat() { + async loginChat(responseChat = this.ValidatedUserChat) { - const expirationMinutes = 30; + this.ValidatedUserChat = responseChat; + localStorage.setItem('userChat', JSON.stringify(responseChat)); + this.storageService.store(AuthConnstants.AUTH, responseChat); + + /* const expirationMinutes = 30; let date = new Date().getTime(); let expirationDate = new Date(new Date().getTime() + expirationMinutes*60*1000); @@ -155,7 +163,7 @@ export class AuthService { let responseChat = await this.httpService.post('login', postData).toPromise(); if(responseChat) { - + console.log() this.ValidatedUserChat = responseChat; localStorage.setItem('userChat', JSON.stringify(responseChat)); this.storageService.store(AuthConnstants.AUTH, responseChat); @@ -165,13 +173,13 @@ export class AuthService { this.presentAlert('Network error'); } - this.autoLoginChat(expirationDate.getTime() - date); + this.autoLoginChat(expirationDate.getTime() - date); */ } async autoLoginChat(expirationDate:number) { - setTimeout(()=>{ - this.loginChat(); - }, expirationDate) + /* setTimeout(()=>{ + this.loginChat(this.ValidatedUserChat); + }, expirationDate) */ } loginToChatWs() { @@ -179,6 +187,7 @@ export class AuthService { this.WsChatService.connect(); this.WsChatService.login().then((message: any) => { + console.log('loginToChatWs',message) SessionStore.user.RochetChatUserId = message.result.id SessionStore.save() diff --git a/src/app/services/chat.service.ts b/src/app/services/chat.service.ts index 5be562fd6..ccbabdccf 100644 --- a/src/app/services/chat.service.ts +++ b/src/app/services/chat.service.ts @@ -38,8 +38,9 @@ export class ChatService { if(this.p.userPermission(this.p.permissionList.Chat.access)) { - this.headers = this.headers.set('X-User-Id', this.loggedUserChat['data'].userId); - this.headers = this.headers.set('X-Auth-Token', this.loggedUserChat['data'].authToken); + console.log(this.loggedUserChat) + this.headers = this.headers.set('X-User-Id', this.loggedUserChat.userId); + this.headers = this.headers.set('X-Auth-Token', this.loggedUserChat.authToken); this.options = { headers: this.headers, }; diff --git a/src/environments/environment.prod.ts b/src/environments/environment.prod.ts index 0a5b0df12..4f208f1ed 100644 --- a/src/environments/environment.prod.ts +++ b/src/environments/environment.prod.ts @@ -1,8 +1,11 @@ export const environment = { - apiURL: 'https://gabinetedigital.dyndns.info/GabineteDigital.Services/V5/api/', - apiChatUrl: 'https://gabinetedigitalchat.dyndns.info/api/v1/', - apiWsChatUrl: 'wss://gabinetedigitalchat.dyndns.info/websocket', + //apiURL: 'https://gabinetedigital.dyndns.info/GabineteDigital.Services/V5/api/', + apiURL: 'https://gpr-dev-01.gabinetedigital.local/GabineteDigital.Services/V5/api/', + //apiChatUrl: 'https://gabinetedigitalchat.dyndns.info/api/v1/', + //apiWsChatUrl: 'wss://gabinetedigitalchat.dyndns.info/websocket', + apiChatUrl: 'https://www.tabularium.pt/api/v1/', + apiWsChatUrl: 'wss://www.tabularium.pt/websocket', //apiChatUrl: 'https://www.tabularium.pt/api/v1/', production: true,