mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-18 20:47:54 +00:00
auto login chat
This commit is contained in:
@@ -103,44 +103,41 @@ export class AuthService {
|
||||
}
|
||||
}
|
||||
|
||||
//Login to rocketChat server
|
||||
async loginChat(user: UserForm) {
|
||||
const expireDate = new Date(new Date().getTime() + 60*1000);
|
||||
//Login to rocketChat server2
|
||||
//user: UserForm
|
||||
async loginChat(user: any) {
|
||||
|
||||
const expirationMinutes = 60;
|
||||
let date = new Date().getTime();
|
||||
let expirationDate = new Date(new Date().getTime() + expirationMinutes*60*1000);
|
||||
|
||||
let postData = {
|
||||
"user": user.username,
|
||||
"password": user.password,
|
||||
"user": user.RochetChatUser,
|
||||
"password": user.Password,
|
||||
}
|
||||
|
||||
let responseChat = await this.httpService.post('login', postData).toPromise();
|
||||
|
||||
if(responseChat) {
|
||||
|
||||
setTimeout(()=>{
|
||||
|
||||
this.WsChatService.connect();
|
||||
this.WsChatService.login().then((message) => {
|
||||
console.log('rocket chat login successfully', message)
|
||||
this.WsChatService.setStatus('online')
|
||||
}).catch((message)=>{
|
||||
console.log('rocket chat login failed', message)
|
||||
})
|
||||
}, 1)
|
||||
|
||||
console.log('Login to Rocket chat OK');
|
||||
console.log('Login to Rocket chat OK', responseChat);
|
||||
this.ValidatedUserChat = responseChat;
|
||||
localStorage.setItem('userChat', JSON.stringify(responseChat));
|
||||
this.storageService.store(AuthConnstants.AUTH, responseChat);
|
||||
|
||||
this.autologout(10000);
|
||||
|
||||
return true;
|
||||
|
||||
//return true;
|
||||
}
|
||||
else{
|
||||
console.log('Network error');
|
||||
this.presentAlert('Network error');
|
||||
return false;
|
||||
//return false;
|
||||
}
|
||||
|
||||
this.autoLoginChat(expirationDate.getTime() - date, user);
|
||||
}
|
||||
|
||||
async autoLoginChat(expirationDate:number, user:any){
|
||||
setTimeout(()=>{
|
||||
this.loginChat(user);
|
||||
}, expirationDate)
|
||||
}
|
||||
|
||||
autologout(expirationDate:number){
|
||||
|
||||
Reference in New Issue
Block a user