diff --git a/package-lock.json b/package-lock.json index 8305eea..9215259 100644 Binary files a/package-lock.json and b/package-lock.json differ diff --git a/package.json b/package.json index 6319cbd..689ba7b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "fwdekker.com", - "version": "0.40.7", + "version": "0.40.8", "description": "The source code of [my personal website](https://fwdekker.com/).", "author": "Felix W. Dekker", "browser": "dist/bundle.js", @@ -24,7 +24,7 @@ }, "devDependencies": { "@istanbuljs/nyc-config-typescript": "^1.0.1", - "@types/chai": "^4.2.17", + "@types/chai": "^4.2.18", "@types/js-cookie": "^2.2.6", "@types/mocha": "^8.2.2", "@types/semver": "^6.2.1", @@ -39,12 +39,12 @@ "grunt-webpack": "^4.0.3", "jsdom": "^16.5.3", "jsdom-global": "^3.0.2", - "mocha": "^8.3.2", + "mocha": "^8.4.0", "nyc": "^15.1.0", "ts-loader": "^9.1.2", "ts-node": "^9.1.1", "typescript": "^4.2.4", - "webpack": "^5.36.2", + "webpack": "^5.37.0", "webpack-cli": "^4.7.0" } } diff --git a/src/main/js/UserList.ts b/src/main/js/UserList.ts index 2bcc531..b99197d 100644 --- a/src/main/js/UserList.ts +++ b/src/main/js/UserList.ts @@ -121,7 +121,7 @@ export class UserList { return false; const modifiedUsers = this.users.map(user => user.name === modifiedUser.name ? modifiedUser : user); - this.userFile.open("write"); // Empty file + this.userFile.open("write"); // Empty file modifiedUsers.forEach(user => this.add(user)); return true; } @@ -192,16 +192,15 @@ export class User { * Constructs a new user. * * @param name the name of the user - * @param password the hash of this user's password - * @param home the path to the user's home directory, or `undefined` to use `/home/` + * @param passwordHash the hash of this user's password + * @param home the path to the user's home directory, or an empty string to use `/home/` * @param description the description of the user */ - constructor(name: string, password: string, home: string | undefined = undefined, - description: string | undefined = undefined) { + constructor(name: string, passwordHash: string, home: string = "", description: string = "") { this.name = name; - this.passwordHash = password; - this.home = home ?? `/home/${name}`; - this.description = description ?? ""; + this.passwordHash = passwordHash; + this.home = home; + this.description = description; } @@ -256,13 +255,13 @@ export class User { /** * Sets the path to the user's home directory. * - * @param home the path to the user's home directory to set + * @param home the path to the user's home directory to set, or empty string to use `/home/` */ set home(home: string) { if (home?.includes("|") || home?.includes("\n")) throw new IllegalArgumentError("Home must not contain pipe ('|') or newline character."); - this._home = home; + this._home = home || `/home/${this.name}`; } /**