dummy user login

This commit is contained in:
Evert Prants 2022-04-02 20:41:24 +03:00
parent 54ded0a49b
commit 86c0f1419a
Signed by: evert
GPG Key ID: 1688DA83D222D0B5
2 changed files with 18 additions and 8 deletions

View File

@ -34,6 +34,8 @@ export class ViewCanvas {
private _cursory = 0;
private _relcursorx = 0;
private _relcursory = 0;
private _screencursorx = 0;
private _screencursory = 0;
private _dragging = false;
@ -79,11 +81,11 @@ export class ViewCanvas {
this._relcursorx = Math.floor((this._cursorx - screenX) / pixelSize);
this._relcursory = Math.floor((this._cursory - screenY) / pixelSize);
const snappedX = this._relcursorx * pixelSize + screenX;
const snappedY = this._relcursory * pixelSize + screenY;
this._screencursorx = this._relcursorx * pixelSize + screenX;
this._screencursory = this._relcursory * pixelSize + screenY;
this._cursor.style.top = `${snappedY + pixelSize / 2}px`;
this._cursor.style.left = `${snappedX + pixelSize / 2}px`;
this._cursor.style.top = `${this._screencursory + pixelSize / 2}px`;
this._cursor.style.left = `${this._screencursorx + pixelSize / 2}px`;
this._cursor.style.transform = `scale(${pixelSize})`;
}
@ -109,9 +111,7 @@ export class ViewCanvas {
if (this._dragging) {
this._posx -= offsetX;
this._posy -= offsetY;
}
if (this._dragging) {
this.moveCanvas();
this.moveCursor();
}

View File

@ -50,7 +50,6 @@ passport.use(
profile: any,
done: Function,
) {
console.log(profile);
process.nextTick(function () {
return done(null, profile);
});
@ -114,12 +113,23 @@ const canvas = new Canvas(config.game.boardSize);
const connections: Socket[] = [];
const changes: CanvasRecord[] = [];
const dummyUser: IcyNetUser = {
id: 0,
username: 'placer',
display_name: 'placer',
uuid: 'placer',
accessToken: 'placer',
};
io.use((socket, next) =>
sessionMiddleware(socket.request as any, {} as any, next as any),
);
io.on('connection', (socket) => {
const session = (socket.request as any).session;
const user = session?.passport?.user as IcyNetUser;
const user =
process.env.SKIP_LOGIN === 'true'
? dummyUser
: (session?.passport?.user as IcyNetUser);
connections.push(socket);
socket.emit(