This commit is contained in:
Kim Ravn Hansen
2025-10-21 11:50:15 +02:00
parent 8a8434f5ac
commit 0b540414ec
9 changed files with 211 additions and 210 deletions

View File

@@ -1,5 +1,5 @@
import { Prompt } from "../prompt.js";
import * as security from "../../utils/security.js";
import { Security } from "../../utils/security.js";
import { Config } from "../../config.js";
export class CreatePasswordPrompt extends Prompt {
@@ -23,7 +23,7 @@ export class CreatePasswordPrompt extends Prompt {
// not hashing an insane password 1000+ times.
// This is technically bad practice, but since this is just a game,
// do it anyway.
if (!security.isPasswordSane(text)) {
if (!Security.isPasswordSane(text)) {
this.sendError("Insane password");
this.execute();
return;
@@ -50,7 +50,7 @@ export class CreatePasswordPrompt extends Prompt {
//
// Verify the password against the hash we've stored.
if (!security.verifyPassword(text, this.player.passwordHash)) {
if (!Security.verifyPassword(text, this.player.passwordHash)) {
this.sendError("Incorrect password!");
this.player.failedPasswordsSinceLastLogin++;

View File

@@ -1,5 +1,5 @@
import { Prompt } from "../prompt.js";
import * as security from "../../utils/security.js";
import { Security } from "../../utils/security.js";
import { gGame } from "../../models/globals.js";
/** @typedef {import("./playerCreationScene.js").PlayerCreationScene} PlayerCreationScene */
@@ -35,7 +35,7 @@ export class CreateUsernamePrompt extends Prompt {
onReply(username) {
//
// do basic syntax checks on usernames
if (!security.isUsernameSane(username)) {
if (!Security.isUsernameSane(username)) {
console.info("Someone entered insane username: '%s'", username);
this.sendError("Incorrect username, try again.");
this.execute();

View File

@@ -1,6 +1,6 @@
import { Config } from "../../config.js";
import { gGame } from "../../models/globals.js";
import { generateHash } from "../../utils/security.js";
import { Security } from "../../utils/security.js";
import { Scene } from "../scene.js";
import { CreateUsernamePrompt } from "./createUsernamePrompt.js";
@@ -48,6 +48,6 @@ export class PlayerCreationScene extends Scene {
passwordAccepted(password) {
this.password = password;
this.session.sendText("*_Success_* ✅ You will now be asked to log in again, sorry for that ;)");
this.player.setPasswordHash(generateHash(this.password));
this.player.setPasswordHash(Security.generateHash(this.password));
}
}