add length option to template

This commit is contained in:
Andras Bacsai
2022-10-17 14:55:28 +00:00
parent 8f660c0276
commit 9afb713df1
3 changed files with 45 additions and 41 deletions

View File

@@ -159,6 +159,9 @@ export default [
"label": "Secret Key Base",
"defaultValue": "$$generate_passphrase",
"description": "",
"details": {
"length":64
}
},
{
"id": "$$config_disable_auth",

View File

@@ -221,9 +221,11 @@ export async function saveServiceType(request: FastifyRequest<SaveServiceType>,
let { id: variableId } = variable;
if (variableId.startsWith('$$secret_')) {
if (variable.defaultValue === '$$generate_password') {
variable.value = generatePassword({});
const length = variable?.details['length'] || null
variable.value = generatePassword({length});
} else if (variable.defaultValue === '$$generate_passphrase') {
variable.value = cuid();
const length = variable?.details['length'] || null
variable.value = generatePassword({length});
}
}
if (variableId.startsWith('$$config_')) {