mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-18 20:47:54 +00:00
fix login
This commit is contained in:
@@ -106,40 +106,41 @@ export class AuthService {
|
||||
}
|
||||
|
||||
//Login to rocketChat server
|
||||
async loginChat(user: UserForm): Promise<boolean> {
|
||||
async loginChat(user: UserForm) {
|
||||
let postData = {
|
||||
"user": user.username,
|
||||
"password": user.password,
|
||||
}
|
||||
|
||||
|
||||
this.WsChatService.connect();
|
||||
this.WsChatService.login().then((message) => {
|
||||
console.log('rocket chat login successfully', message)
|
||||
this.WsChatService.temporaryStatus('online')
|
||||
}).catch((message)=>{
|
||||
console.log('rocket chat login failed', message)
|
||||
})
|
||||
setTimeout(()=>{
|
||||
this.WsChatService.connect();
|
||||
this.WsChatService.login().then((message) => {
|
||||
console.log('rocket chat login successfully', message)
|
||||
this.WsChatService.temporaryStatus('online')
|
||||
}).catch((message)=>{
|
||||
console.log('rocket chat login failed', message)
|
||||
})
|
||||
}, 1)
|
||||
|
||||
// let responseChat = await this.httpService.post('login', postData).toPromise();
|
||||
|
||||
let responseChat = await this.httpService.post('login', postData).toPromise();
|
||||
|
||||
if(responseChat) {
|
||||
console.log('Login to Rocket chat OK');
|
||||
this.ValidatedUserChat = responseChat;
|
||||
localStorage.setItem('userChat', JSON.stringify(responseChat));
|
||||
localStorage.setItem('Meteor.loginToken', responseChat['data'].authToken);
|
||||
localStorage.setItem('Meteor.userId',responseChat['data'].userId);
|
||||
this.cookieService.set('rc_token', responseChat['data'].authToken);
|
||||
this.cookieService.set('rc_uid', responseChat['data'].userId);
|
||||
this.storageService.store(AuthConnstants.AUTH, responseChat);
|
||||
return true;
|
||||
}
|
||||
else{
|
||||
console.log('Network error');
|
||||
this.presentAlert('Network error');
|
||||
return false;
|
||||
}
|
||||
// if(responseChat) {
|
||||
// console.log('Login to Rocket chat OK');
|
||||
// this.ValidatedUserChat = responseChat;
|
||||
// localStorage.setItem('userChat', JSON.stringify(responseChat));
|
||||
// localStorage.setItem('Meteor.loginToken', responseChat['data'].authToken);
|
||||
// localStorage.setItem('Meteor.userId',responseChat['data'].userId);
|
||||
// this.cookieService.set('rc_token', responseChat['data'].authToken);
|
||||
// this.cookieService.set('rc_uid', responseChat['data'].userId);
|
||||
// this.storageService.store(AuthConnstants.AUTH, responseChat);
|
||||
// return true;
|
||||
// }
|
||||
// else{
|
||||
// console.log('Network error');
|
||||
// this.presentAlert('Network error');
|
||||
// return false;
|
||||
// }
|
||||
}
|
||||
|
||||
//Get user data from RocketChat | global object
|
||||
|
||||
Reference in New Issue
Block a user