This commit is contained in:
tiago.kayaya
2022-01-12 09:29:48 +01:00
parent f90773459c
commit d0b1401d42
7 changed files with 72 additions and 19 deletions
+25 -4
View File
@@ -11,6 +11,8 @@ import { SessionStore } from '../store/session.service';
import { AESEncrypt } from '../services/aesencrypt.service';
import { CookieService } from 'ngx-cookie-service';
import { RocketChatClientService } from '../services/socket/rocket-chat-client.service';
import { ChatService } from './chat.service';
import { WebsocketService } from './websocket.service';
@Injectable({
providedIn: 'root'
@@ -20,7 +22,9 @@ export class AuthService {
userId$ = new BehaviorSubject<any>('');
headers: HttpHeaders;
public ValidatedUser: UserSession;
public wsValidatedUserChat:any;
public ValidatedUserChat:any;
public isWsAuthenticated: boolean = false;
opts:any;
constructor(
@@ -30,6 +34,7 @@ export class AuthService {
public alertController: AlertController,
private aesencrypt: AESEncrypt,
private cookieService: CookieService,
private wsService: WebsocketService,
private RocketChatClientService: RocketChatClientService) {
this.headers = new HttpHeaders();
@@ -38,7 +43,7 @@ export class AuthService {
this.ValidatedUser = SessionStore.user
console.log('login', SessionStore.user.RochetChatUser, SessionStore.user.Password)
this.RocketChatClientService.connect(()=>{
/* this.RocketChatClientService.connect(()=>{
this.RocketChatClientService.login({
username: SessionStore.user.RochetChatUser,
password: SessionStore.user.Password
@@ -47,7 +52,7 @@ export class AuthService {
}).catch((message)=>{
console.log('rocket chat login failed', message)
})
})
}) */
}
@@ -107,6 +112,22 @@ export class AuthService {
this.ValidatedUser = null;
}
loginWsChat(){
let msg = {
"msg": "method",
"method": "login",
"id":"42",
"params":[
{
"user": { "username": "paulo.pinto" },
"password": "tabteste@006"
}
]
}
this.wsService.messages.next(msg);
this.isWsAuthenticated = true;
}
//Login to rocketChat server
async loginChat(user: UserForm): Promise<boolean> {
let postData = {
@@ -115,7 +136,7 @@ export class AuthService {
}
this.RocketChatClientService.connect(()=>{
/* this.RocketChatClientService.connect(()=>{
this.RocketChatClientService.login({
username: SessionStore.user.RochetChatUser,
@@ -127,7 +148,7 @@ export class AuthService {
}).finally(()=>{
})
})
}) */
let responseChat = await this.httpService.post('login', postData).toPromise();