partey_workadventure/front/src/Connexion/LocalUser.ts

30 lines
852 B
TypeScript
Raw Normal View History

import {MAX_USERNAME_LENGTH} from "../Enum/EnvironmentVariable";
2020-10-20 16:39:23 +02:00
export interface CharacterTexture {
id: number,
level: number,
url: string,
rights: string
}
export const maxUserNameLength: number = MAX_USERNAME_LENGTH;
export function isUserNameValid(value: unknown): boolean {
2021-05-31 17:03:29 +02:00
return typeof value === "string" && value.length > 0 && value.length <= maxUserNameLength && value.indexOf(' ') === -1;
}
export function areCharacterLayersValid(value: string[] | null): boolean {
if (!value || !value.length) return false;
for (let i = 0; i < value.length; i++) {
if (/^\w+$/.exec(value[i]) === null) {
return false;
}
}
return true;
}
export class LocalUser {
constructor(public readonly uuid:string, public readonly jwtToken: string, public textures: CharacterTexture[]) {
}
2020-10-20 16:39:23 +02:00
}