server: somewhat type fix auth related functions

The auth functions are a bloody mess and need to be cleaned up.
using various callback functions and using variables as pointers makes the logic
hard to follow and hence idiotic to type too, as multiple orthogonal logic paths
are mixed up into one function.

This really needs to be untangled
This commit is contained in:
Reto Brunner 2024-04-17 17:43:52 +02:00
commit e61e356f1e
2 changed files with 70 additions and 28 deletions

View file

@ -101,17 +101,19 @@ interface ServerToClientEvents {
}>;
}
type AuthPerformData =
| Record<string, never> // funny way of saying an empty object
| {user: string; password: string}
| {
user: string;
token: string;
lastMessage: number;
openChannel: number | null;
hasConfig: boolean;
};
interface ClientToServerEvents {
"auth:perform": EventHandler<
| {user: string; password: string}
| {
user: string;
token: string;
lastMessage: number;
openChannel: number | null;
hasConfig: boolean;
}
>;
"auth:perform": EventHandler<AuthPerformData>;
changelog: NoPayloadEventHandler;