mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-18 20:47:54 +00:00
Login user parametrization
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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();
|
||||
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -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,
|
||||
};
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user