mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-04-27 07:48:01 -07:00
Some checks failed
Build Desktop / Configure (push) Has been cancelled
Build Docker Image / amd64 & arm64 (push) Has been cancelled
Build Web / React (Node 16) (push) Has been cancelled
Build Web / React (Node lts/*) (push) Has been cancelled
Build Desktop / Debian 11 (push) Has been cancelled
Build Desktop / Debian 13 (push) Has been cancelled
Build Desktop / Debian 12 (push) Has been cancelled
Build Desktop / Fedora 43 (push) Has been cancelled
Build Desktop / Fedora 42 (push) Has been cancelled
Build Desktop / Servatrice_Debian 11 (push) Has been cancelled
Build Desktop / Ubuntu 24.04 (push) Has been cancelled
Build Desktop / Ubuntu 26.04 (push) Has been cancelled
Build Desktop / Ubuntu 22.04 (push) Has been cancelled
Build Desktop / Arch (push) Has been cancelled
Build Desktop / macOS 14 (push) Has been cancelled
Build Desktop / macOS 15 (push) Has been cancelled
Build Desktop / macOS 13 Intel (push) Has been cancelled
Build Desktop / macOS 15 Debug (push) Has been cancelled
Build Desktop / Windows 10 (push) Has been cancelled
55 lines
1.8 KiB
TypeScript
55 lines
1.8 KiB
TypeScript
import { StatusEnum, User, WebSocketConnectReason, WebSocketConnectOptions } from 'types';
|
|
import { SessionCommands, webClient } from 'websocket';
|
|
import { ProtoController } from 'websocket/services/ProtoController';
|
|
|
|
export class AuthenticationService {
|
|
static login(options: WebSocketConnectOptions): void {
|
|
SessionCommands.connect(options, WebSocketConnectReason.LOGIN);
|
|
}
|
|
|
|
static testConnection(options: WebSocketConnectOptions): void {
|
|
SessionCommands.connect(options, WebSocketConnectReason.TEST_CONNECTION);
|
|
}
|
|
|
|
static register(options: WebSocketConnectOptions): void {
|
|
SessionCommands.connect(options, WebSocketConnectReason.REGISTER);
|
|
}
|
|
|
|
static activateAccount(options: WebSocketConnectOptions): void {
|
|
SessionCommands.connect(options, WebSocketConnectReason.ACTIVATE_ACCOUNT);
|
|
}
|
|
|
|
static resetPasswordRequest(options: WebSocketConnectOptions): void {
|
|
SessionCommands.connect(options, WebSocketConnectReason.PASSWORD_RESET_REQUEST);
|
|
}
|
|
|
|
static resetPasswordChallenge(options: WebSocketConnectOptions): void {
|
|
SessionCommands.connect(options, WebSocketConnectReason.PASSWORD_RESET_CHALLENGE);
|
|
}
|
|
|
|
static resetPassword(options: WebSocketConnectOptions): void {
|
|
SessionCommands.connect(options, WebSocketConnectReason.PASSWORD_RESET);
|
|
}
|
|
|
|
static disconnect(): void {
|
|
SessionCommands.disconnect();
|
|
}
|
|
|
|
static isConnected(state: number): boolean {
|
|
return state === StatusEnum.LOGGED_IN;
|
|
}
|
|
|
|
static isModerator(user: User): boolean {
|
|
const moderatorLevel = ProtoController.root.ServerInfo_User.UserLevelFlag.IsModerator;
|
|
// @TODO tell cockatrice not to do this so shittily
|
|
return (user.userLevel & moderatorLevel) === moderatorLevel;
|
|
}
|
|
|
|
static isAdmin() {
|
|
|
|
}
|
|
|
|
static connectionAttemptMade() {
|
|
return webClient.connectionAttemptMade;
|
|
}
|
|
}
|