converted to express, with sessions, no more login proc

This commit is contained in:
STEINNI
2025-09-15 19:13:05 +00:00
parent b4cd02add5
commit e7dcb7290e
5 changed files with 126 additions and 100 deletions
+27 -24
View File
@@ -1,8 +1,6 @@
import {AccesRights} from './accesRights.js'
import crypto from 'crypto'
import {WssConnexion} from './wssConnexion.js'
import session from 'express-session'
import connectMySQL from 'express-mysql-session'
export class wssServer {
@@ -32,29 +30,34 @@ export class wssServer {
newWSSConnexion(socket, req) {
var uuid = crypto.randomUUID();
var wssCnx = new WssConnexion({
socket: socket,
req, req,
uuid: uuid,
wssSrv: this,
debug: this.debug,
config: this.wssGatewayConfig,
rediscnx: this.REDIScnx,
accessRights: this.accessRights,
});
this.AllWssConnections[uuid] = wssCnx;
wssCnx.doLogin().then(() => { // Things to execute only when successfuly logged-in
if(!(wssCnx.userId in this.Users2uuids)) this.Users2uuids[wssCnx.userId] = new Set();
this.Users2uuids[wssCnx.userId].add(uuid);
this.OnlineUsers.add(wssCnx.userId);
this.REDIScnx.wssConnections[uuid] = wssCnx;
//}).then(() => {
wssCnx.send(JSON.stringify({
'action': 'LOGIN',
'logged': true
}))
if(socket.session && socket.session.authenticated && socket.session.userInfos && socket.session.userInfos.username){
var wssCnx = new WssConnexion({
socket: socket,
req, req,
uuid: uuid,
wssSrv: this,
debug: this.debug,
config: this.wssGatewayConfig,
rediscnx: this.REDIScnx,
accessRights: this.accessRights,
});
this.AllWssConnections[uuid] = wssCnx;
this.postLoginActions(wssCnx)
})
} else socket.close()
// wssCnx.doLogin().then(() => { // Things to execute only when successfuly logged-in
// if(!(wssCnx.userId in this.Users2uuids)) this.Users2uuids[wssCnx.userId] = new Set();
// this.Users2uuids[wssCnx.userId].add(uuid);
// this.OnlineUsers.add(wssCnx.userId);
// this.REDIScnx.wssConnections[uuid] = wssCnx;
// //}).then(() => {
// wssCnx.send(JSON.stringify({
// 'action': 'LOGIN',
// 'logged': true
// }))
// this.postLoginActions(wssCnx)
// })
}
postLoginActions(wssCnx) {