This commit is contained in:
58
startos/actions/resetPassword.ts
Normal file
58
startos/actions/resetPassword.ts
Normal file
@@ -0,0 +1,58 @@
|
||||
import { storeJson } from '../fileModels/storeJson'
|
||||
import { i18n } from '../i18n'
|
||||
import { sdk } from '../sdk'
|
||||
import { APP_USER, randomPassword } from '../utils'
|
||||
|
||||
export const resetPassword = sdk.Action.withoutInput(
|
||||
// id
|
||||
'reset-password',
|
||||
|
||||
// metadata
|
||||
async ({ effects }) => ({
|
||||
name: i18n('Reset Web UI Password'),
|
||||
description: i18n(
|
||||
'Generate a new admin password for the Spaces web terminal',
|
||||
),
|
||||
warning: null,
|
||||
allowedStatuses: 'any',
|
||||
group: null,
|
||||
visibility: 'enabled',
|
||||
}),
|
||||
|
||||
// run
|
||||
async ({ effects }) => {
|
||||
const password = randomPassword()
|
||||
await storeJson.merge(effects, { password })
|
||||
|
||||
return {
|
||||
version: '1',
|
||||
title: i18n('Success'),
|
||||
message: i18n(
|
||||
'Use these credentials to log in to the Spaces web terminal.',
|
||||
),
|
||||
result: {
|
||||
type: 'group',
|
||||
value: [
|
||||
{
|
||||
type: 'single',
|
||||
name: i18n('Username'),
|
||||
description: null,
|
||||
value: APP_USER,
|
||||
masked: false,
|
||||
copyable: true,
|
||||
qr: false,
|
||||
},
|
||||
{
|
||||
type: 'single',
|
||||
name: i18n('Password'),
|
||||
description: null,
|
||||
value: password,
|
||||
masked: true,
|
||||
copyable: true,
|
||||
qr: false,
|
||||
},
|
||||
],
|
||||
},
|
||||
}
|
||||
},
|
||||
)
|
||||
Reference in New Issue
Block a user