Browse Source

update: add docs

- README: init password
- add docs support to database interface
pull/1228/head
tetuaoro 2 years ago
parent
commit
d23be741c9
  1. 6
      README.md
  2. 23
      src/lib/database/AbstractDatabase.js

6
README.md

@ -95,6 +95,12 @@ execute `docker compose up --detach`.
Are you enjoying this project? [Buy Emile a beer!](https://github.com/sponsors/WeeJeWel) 🍻 Are you enjoying this project? [Buy Emile a beer!](https://github.com/sponsors/WeeJeWel) 🍻
## Password initialization
When the application initializes the database for the first time, it sets up an admin user with a default password : `admin`. You have the option to set your own password instead using either the `PASSWORD` environment variable or the `PASSWORD_HASH` environment variable. Follow [this link](./How_to_generate_an_bcrypt_hash.md) to generate a bcrypt hash password.
The `PASSWORD` environment variable is plain text and will be hashed at runtime by wg-easy. On the other hand, the `PASSWORD_HASH` environment variable is already hashed.
## Options ## Options
These options can be configured by setting environment variables using `-e KEY="VALUE"` in the `docker run` command. These options can be configured by setting environment variables using `-e KEY="VALUE"` in the `docker run` command.

23
src/lib/database/AbstractDatabase.js

@ -10,14 +10,37 @@ module.exports = class DatabaseInterface {
} }
} }
/**
* Initializes the database if does not exist
*
* @returns {Promise<void>}
* @throws {ServerError} If not implemented by the subclass
*/
async initDb() { async initDb() {
throw new ServerError('You must implement this function'); throw new ServerError('You must implement this function');
} }
/**
* Compares the provided password with the stored password for the given username
*
* @param {string} username - The username of the user
* @param {string} password - The password to compare
* @returns {Promise<boolean>} - Return `true` if the password matches, otherwise `false`
* @throws {ServerError} If not implemented by the subclass
*/
async comparePassword(username, password) { async comparePassword(username, password) {
throw new ServerError('You must implement this function'); throw new ServerError('You must implement this function');
} }
/**
* Updates the password for the given user
*
* @param {string} username - The username of the user
* @param {string} oldPassword - The current password of the user
* @param {string} newPassword - The new password to set
* @returns {Promise<void>}
* @throws {ServerError} If not implemented by the subclass
*/
async updatePassword(username, oldPassword, newPassword) { async updatePassword(username, oldPassword, newPassword) {
throw new ServerError('You must implement this function'); throw new ServerError('You must implement this function');
} }

Loading…
Cancel
Save