mirror of
https://github.com/nicotsx/zerobyte.git
synced 2026-07-31 10:06:05 -04:00
* feat: add option to disable password login Adds a global admin setting to hide the username/password form on the login page, useful for deployments that rely solely on SSO/OIDC or passkeys. The form defaults to enabled so existing deployments are unaffected. Changes: - Add PASSWORD_LOGIN_ENABLED_KEY constant - Add isPasswordLoginEnabled / setPasswordLoginEnabled to system service (defaults to true when no DB record exists) - Add GET/PUT /api/v1/system/password-login-status endpoints (GET auth-gated for admin use; setting is exposed to the login page via the existing getLoginOptions server function) - Extend getLoginOptions to include passwordLoginEnabled - Conditionally render the password login form in LoginPage - Add "Enable password login" toggle in the admin System Settings tab, next to "Enable new user registrations" - Add corresponding entries to generated API client files (types.gen.ts, sdk.gen.ts, @tanstack/react-query.gen.ts) Closes #941 * fix(login): show errors even if password is disabled * feat(cli): add command to re-enable password --------- Co-authored-by: Nicolas Meienberger <github@thisprops.com>
57 lines
1.6 KiB
TypeScript
57 lines
1.6 KiB
TypeScript
import { Command } from "commander";
|
|
import { assignOrganizationCommand } from "./commands/assign-organization";
|
|
import { changeEmailCommand } from "./commands/change-email";
|
|
import { changeUsernameCommand } from "./commands/change-username";
|
|
import { disable2FACommand } from "./commands/disable-2fa";
|
|
import { enablePasswordLoginCommand } from "./commands/enable-password-login";
|
|
import { rekey2FACommand } from "./commands/rekey-2fa";
|
|
import { resetPasswordCommand } from "./commands/reset-password";
|
|
import { config } from "../core/config";
|
|
import { db } from "../db/db";
|
|
|
|
const program = new Command();
|
|
|
|
program
|
|
.name("zerobyte")
|
|
.description("Zerobyte CLI - Backup automation tool built on top of Restic")
|
|
.version(config.appVersion);
|
|
program.addCommand(resetPasswordCommand);
|
|
program.addCommand(disable2FACommand);
|
|
program.addCommand(enablePasswordLoginCommand);
|
|
program.addCommand(changeUsernameCommand);
|
|
program.addCommand(changeEmailCommand);
|
|
program.addCommand(rekey2FACommand);
|
|
program.addCommand(assignOrganizationCommand);
|
|
|
|
export async function runCLI(argv: string[]): Promise<boolean> {
|
|
db.run("PRAGMA foreign_keys = ON;");
|
|
|
|
const args = argv.slice(2);
|
|
const isCLIMode = process.env.ZEROBYTE_CLI === "1";
|
|
|
|
if (args.length === 0) {
|
|
if (isCLIMode) {
|
|
program.help();
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
if (!isCLIMode && args[0].startsWith("-")) {
|
|
return false;
|
|
}
|
|
|
|
await program.parseAsync(argv).catch((err) => {
|
|
if (err.message.includes("SIGINT")) {
|
|
process.exit(0);
|
|
}
|
|
|
|
console.error(err.message);
|
|
process.exit(1);
|
|
});
|
|
|
|
return true;
|
|
}
|
|
|
|
export { program };
|