Add startos/actions/set-admin-password.ts
Add admin password action
This commit is contained in:
@@ -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,
|
||||
}),
|
||||
)
|
||||
Reference in New Issue
Block a user