mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-18 20:47:54 +00:00
improve login to rocket chat via websocket
This commit is contained in:
@@ -30,12 +30,25 @@ export class AuthService {
|
||||
public alertController: AlertController,
|
||||
private aesencrypt: AESEncrypt,
|
||||
private cookieService: CookieService,
|
||||
private RocketChatClientService: RocketChatClientService
|
||||
) {
|
||||
|
||||
this.headers = new HttpHeaders();
|
||||
|
||||
if (SessionStore.exist) {
|
||||
this.ValidatedUser = SessionStore.user
|
||||
|
||||
this.RocketChatClientService.connect(()=>{
|
||||
this.RocketChatClientService.login({
|
||||
username: SessionStore.user.UserName,
|
||||
password: SessionStore.user.Password
|
||||
}).then((message) => {
|
||||
console.log('rocket chat login successfully', message)
|
||||
}).catch((message)=>{
|
||||
console.log('rocket chat login failed', message)
|
||||
})
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
if (localStorage.getItem("userChat") != null) {
|
||||
@@ -77,6 +90,8 @@ export class AuthService {
|
||||
session.Profile = 'MDGPR'
|
||||
}
|
||||
|
||||
session.Password = user.password
|
||||
|
||||
session.BasicAuthKey = user.BasicAuthKey
|
||||
|
||||
SessionStore.reset(session)
|
||||
@@ -98,6 +113,22 @@ export class AuthService {
|
||||
"password": user.password,
|
||||
}
|
||||
|
||||
|
||||
this.RocketChatClientService.connect(()=>{
|
||||
|
||||
this.RocketChatClientService.login({
|
||||
username: user.username,
|
||||
password: user.password
|
||||
}).then((message) => {
|
||||
console.log('rocket chat login successfully', message)
|
||||
}).catch((message)=>{
|
||||
console.log('rocket chat login failed', message)
|
||||
}).finally(()=>{
|
||||
})
|
||||
|
||||
})
|
||||
|
||||
|
||||
let responseChat = await this.httpService.post('login', postData).toPromise();
|
||||
if(responseChat) {
|
||||
console.log('Login to Rocket chat OK');
|
||||
|
||||
Reference in New Issue
Block a user