feat(accounts): implement local login
Route login and character requests by their original host names on one loopback port. Add local accounts, saves, and credential redaction.
This commit is contained in:
1 parent
c3914ec0d6
commit
7f482ae530
55 files changed
+1559
-58
No files matched your search
@@ -0,0 +1,9 @@
|
||||
/**
|
||||
* A new account's profile. The starting content is Gaijin's own new-account template from
|
||||
* the player's game files (config/default_user.blk), copied as it is.
|
||||
*/
|
||||
import type { BlkBlock } from '@wto/blk';
|
||||
|
||||
export function newProfile(template: BlkBlock): BlkBlock {
|
||||
return structuredClone(template);
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
/**
|
||||
* The one way services get a player's profile: the saved one, or a new one that is written
|
||||
* to the save before it is handed out.
|
||||
*/
|
||||
import type { BlkBlock } from '@wto/blk';
|
||||
import type { GameFiles } from '../game-data/game-files.ts';
|
||||
import type { SaveStore } from '../saves/save-store.ts';
|
||||
import { newProfile } from './new-profile.ts';
|
||||
|
||||
export class PlayerProfiles {
|
||||
readonly #saves: SaveStore;
|
||||
readonly #gameFiles: GameFiles;
|
||||
|
||||
constructor(saves: SaveStore, gameFiles: GameFiles) {
|
||||
this.#saves = saves;
|
||||
this.#gameFiles = gameFiles;
|
||||
}
|
||||
|
||||
profileOf(userId: string): BlkBlock {
|
||||
const saved = this.#saves.loadProfile(userId);
|
||||
if (saved) return saved;
|
||||
const created = newProfile(this.#gameFiles.newAccountTemplate());
|
||||
this.#saves.saveProfile(userId, created);
|
||||
return created;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user