WS login not working

This commit is contained in:
Eudes Inácio
2022-04-18 14:32:21 +01:00
15 changed files with 105 additions and 56 deletions
+17 -8
View File
@@ -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,20 +173,21 @@ 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() {
setTimeout(()=>{
console.log('loginToChatWs')
this.WsChatService.connect();
this.WsChatService.login().then((message: any) => {
console.log('loginToChatWs',message)
SessionStore.user.RochetChatUserId = message.result.id
SessionStore.save()