This commit is contained in:
2025-09-11 19:47:33 -04:00
parent 317da3aaf7
commit c2eb111291
14 changed files with 217 additions and 44 deletions

View File

@@ -14,6 +14,7 @@ import { ProfileSettingsManager } from "./content/Settings.ts";
import { ProfileSubscriptionsManager } from "./content/Subscriptions.ts";
import ProfileManagerBase from "./manager.ts";
import { recNetAccountSchema, SelfAccount, type RecNetAccount } from "./types/profile.ts";
import { hash, verify } from "@felix/bcrypt";
class Profile {
@@ -95,7 +96,7 @@ class Profile {
async getRole(): Promise<ProfileRole> {
const val = (await this.#kv.getKv().get<ProfileRole>(this.constructProfilePropertyKey('role'))).value;
if (!val) return ProfileRole.Game;
if (!val) return "gameClient";
else return val;
}
@@ -146,8 +147,8 @@ class Profile {
if (this.#instance) this.#instance.removePlayer(this);
inst.addPlayer(this);
this.#server.emit('presence.update', { profile: this, presence: this.#server.Presence.getPresence(this) });
this.#instance = inst;
this.#server.emit('presence.update', { profile: this, presence: this.#server.Presence.getPresence(this) });
}
getId() {
@@ -176,6 +177,15 @@ class Profile {
return profile.getId() == this.getId();
}
async setPassword(pass: string) {
await this.#kv.getKv().set(this.constructProfilePropertyKey("password"), await hash(pass));
}
async verifyPassword(pass: string) {
const hash = await this.#kv.getKv().get<string>(this.constructProfilePropertyKey("password"));
if (hash.value == null) return false;
else return await verify(pass, hash.value);
}
}
export default Profile;