diff --git a/startos/actions/set-admin-password.ts b/startos/actions/set-admin-password.ts new file mode 100644 index 0000000..b8ef8b5 --- /dev/null +++ b/startos/actions/set-admin-password.ts @@ -0,0 +1,43 @@ +import { sdk } from '../sdk' +import { store } from '../file-models/store.json' + +const { InputSpec, Value } = sdk + +export const inputSpec = InputSpec.of({ + password: Value.text({ + name: 'Admin password', + description: 'Password used to access the Munin Bitcoin web interface', + required: true, + default: null, + masked: true, + minLength: 12, + placeholder: 'Enter admin password', + }), +}) + +export const setAdminPassword = sdk.Action.withInput( + 'set-admin-password', + + async ({ effects }) => ({ + name: 'Set Admin Password', + description: 'Set the password for the Munin Bitcoin admin user', + warning: null, + allowedStatuses: 'any', + group: null, + visibility: 'enabled', + }), + + inputSpec, + + async ({ effects }) => { + const current = await store.read.const(effects) + return { + password: current?.adminPassword ?? null, + } + }, + + async ({ effects, input }) => + store.merge(effects, { + adminPassword: input.password, + }), +) \ No newline at end of file