mirror of
https://github.com/dec0dOS/zero-ui.git
synced 2024-11-14 12:46:48 +08:00
16 lines
538 B
JavaScript
16 lines
538 B
JavaScript
import crypto from "crypto";
|
|
import hashPassword from "pbkdf2-wrapper/hashText.js";
|
|
|
|
export async function initAdmin() {
|
|
if (!process.env.ZU_DEFAULT_PASSWORD || !process.env.ZU_DEFAULT_USERNAME) {
|
|
console.error("ZU_DEFAULT_PASSWORD or ZU_DEFAULT_USERNAME not found!");
|
|
process.exit(1);
|
|
}
|
|
const username = process.env.ZU_DEFAULT_USERNAME;
|
|
const hash = await hashPassword(process.env.ZU_DEFAULT_PASSWORD);
|
|
return {
|
|
username: username,
|
|
password_hash: hash,
|
|
token: crypto.randomBytes(16).toString("hex"),
|
|
};
|
|
}
|