45 lines
1.0 KiB
TypeScript
45 lines
1.0 KiB
TypeScript
import { store } from '../fileModels/store'
|
|
import { i18n } from '../i18n'
|
|
import { sdk } from '../sdk'
|
|
|
|
const { InputSpec, Value } = sdk
|
|
|
|
const inputSpec = InputSpec.of({
|
|
password: Value.text({
|
|
name: i18n('Password'),
|
|
description: i18n(
|
|
'The password Gunner types on the login screen (at least 4 characters)',
|
|
),
|
|
required: true,
|
|
default: null,
|
|
masked: true,
|
|
minLength: 4,
|
|
}),
|
|
})
|
|
|
|
export const setPassword = sdk.Action.withInput(
|
|
'set-password',
|
|
|
|
async ({ effects }) => ({
|
|
name: i18n('Set Login Password'),
|
|
description: i18n('Set the password Gunner uses to log in to Premier Gunner'),
|
|
warning: null,
|
|
allowedStatuses: 'any',
|
|
group: null,
|
|
visibility: 'enabled',
|
|
}),
|
|
|
|
inputSpec,
|
|
|
|
async ({ effects }) => {
|
|
const password = await store.read((s) => s.password).const(effects)
|
|
return { password: password ?? undefined }
|
|
},
|
|
|
|
async ({ effects, input }) => {
|
|
await store.merge(effects, { password: input.password })
|
|
},
|
|
)
|
|
|
|
export const actions = sdk.Actions.of().addAction(setPassword)
|