This commit is contained in:
Peter Maquiran
2022-05-09 15:01:23 +01:00
parent 578e9eab35
commit 25fec510d9
3 changed files with 31 additions and 35 deletions
+6 -4
View File
@@ -116,17 +116,19 @@ export class LoginPage implements OnInit {
loader.remove() loader.remove()
// login to API successfully // login to API successfully
console.log(attempt,'!!::!!');
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);
if(attempt.ChatData){ if(attempt.ChatData) {
await this.authService.loginChat(attempt.ChatData.data); await this.authService.loginChat(attempt.ChatData.data);
//try { //try {
await this.authService.loginToChatWs(); await this.authService.loginToChatWs();
// } catch(e) {} // } catch(e) {}
} }
@@ -148,7 +150,7 @@ export class LoginPage implements OnInit {
this.changeProfileService.run(); this.changeProfileService.run();
if(attempt.ChatData){ if(attempt.ChatData) {
await this.authService.loginChat(attempt.ChatData.data); await this.authService.loginChat(attempt.ChatData.data);
await this.authService.loginToChatWs(); await this.authService.loginToChatWs();
} }
+11 -14
View File
@@ -55,22 +55,17 @@ export class AuthService {
if (SessionStore.exist) { if (SessionStore.exist) {
this.ValidatedUser = SessionStore.user this.ValidatedUser = SessionStore.user
if(this.p.userPermission(this.p.permissionList.Chat.access) == true ){ if(this.p.userPermission(this.p.permissionList.Chat.access) == true ) {
this.loginToChatWs() this.loginToChatWs()
} }
} }
if (localStorage.getItem("userChat") != null) { if(SessionStore?.user?.ChatData) {
this.ValidatedUserChat = SessionStore.user.ChatData
console.log('!!!!::!!!!', SessionStore.user)
}
if(!this.ValidatedUserChat.hasOwnProperty('data')) {
this.ValidatedUserChat = {
data: JSON.parse(localStorage.getItem('userChat'))
};
} else {
this.ValidatedUserChat = JSON.parse(localStorage.getItem('userChat'))
}
}
} }
@@ -142,6 +137,8 @@ export class AuthService {
SessionStore.reset(session) SessionStore.reset(session)
this.ValidatedUser = SessionStore.user; this.ValidatedUser = SessionStore.user;
console.log('!!!::!!===', this.ValidatedUser)
this.storageService.store(AuthConnstants.USER, response); this.storageService.store(AuthConnstants.USER, response);
return true; return true;
@@ -154,9 +151,9 @@ export class AuthService {
//user: UserForm //user: UserForm
async loginChat(responseChat = this.ValidatedUserChat) { async loginChat(responseChat = this.ValidatedUserChat) {
this.ValidatedUserChat = responseChat; if(SessionStore?.user?.ChatData) {
localStorage.setItem('userChat', JSON.stringify(responseChat)); this.ValidatedUserChat = SessionStore.user.ChatData
this.storageService.store(AuthConnstants.AUTH, responseChat); }
/* const expirationMinutes = 30; /* const expirationMinutes = 30;
let date = new Date().getTime(); let date = new Date().getTime();
+14 -17
View File
@@ -18,9 +18,6 @@ export class ChatService {
options1:any; options1:any;
X_User_Id:any; X_User_Id:any;
X_Auth_Token:any; X_Auth_Token:any;
//SERVER_URL = 'wss://www.tabularium.pt/websocket';
//public messages: Subject<any>;
loggedUserChat:any; loggedUserChat:any;
bindOnMessage: any; bindOnMessage: any;
@@ -32,20 +29,20 @@ export class ChatService {
private storageService:StorageService, private storageService:StorageService,
public p: PermissionService) { public p: PermissionService) {
if(this.p.userPermission(this.p.permissionList.Chat.access)){
this.loggedUserChat = authService.ValidatedUserChat;
this.headers = new HttpHeaders();
if(this.p.userPermission(this.p.permissionList.Chat.access)) { if(this.p.userPermission(this.p.permissionList.Chat.access)) {
// this.loggedUserChat = authService.ValidatedUserChat;
this.headers = this.headers.set('X-User-Id', this.loggedUserChat.userId); this.headers = new HttpHeaders();
this.headers = this.headers.set('X-Auth-Token', this.loggedUserChat.authToken);
this.options = {
headers: this.headers,
};
}
console.log('!!!::!!! chat service',this.loggedUserChat)
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);
this.options = {
headers: this.headers,
};
}
} }
} }
@@ -65,9 +62,9 @@ export class ChatService {
headers: headersc, headers: headersc,
withCredentials: true withCredentials: true
}; };
//let fullUrl = "https://www.tabularium.pt/" + url; // let fullUrl = "https://www.tabularium.pt/" + url;
return this.http.get(url, optionsc).subscribe(()=>{ return this.http.get(url, optionsc).subscribe(()=>{
//this.fileService.viewDocumentByUrl(url) // this.fileService.viewDocumentByUrl(url)
}); });
} }