From 8c7d4778a1e0b53500f6c7beb94acb684cda907a Mon Sep 17 00:00:00 2001 From: Anthony Date: Thu, 10 Apr 2025 20:10:26 +0800 Subject: [PATCH] Updated Change Password --- README.md | 3 +++ manifest.jps | 18 +++++++++++++++--- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 5dc9f84..86cfaf0 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,6 @@ +Version 0.5 Changelogs: +- Replaced Change Password from list of users to input the username and also a field to input the password + Version 0.4 Changelogs: - Replaced auto-generated usernames with user-defined usernames - Added username validation (3-32 characters, alphanumeric + underscore only) diff --git a/manifest.jps b/manifest.jps index ab3657e..64b608a 100644 --- a/manifest.jps +++ b/manifest.jps @@ -1,4 +1,4 @@ -version: 0.4 +version: 0.5 id: addsftp type: update description: An addon to add new SFTP users. It can also manage created user accounts. If SSH is enabled, WP-CLI will attempt to be installed if it is not yet installed. @@ -41,6 +41,12 @@ settings: description: "Input the username you want to manage." required: true values: [] + - type: string + name: custom_password + caption: New Password + description: "Enter a new password or leave empty to generate one automatically" + required: false + inputType: password onBeforeInit: | let cmd = 'ls -ld /home/sftpusers/* | awk \'{printf "%s,%s %s %s\\n", substr($9, 17), $6, $7, $8}\'' @@ -127,10 +133,16 @@ actions: type: info message: "Connection Details\n\nSFTP Host: ${globals.sftpHost}\n\nPort: ${globals.sftpPort}\n\nLogin Credentials\n\nUsername: ${globals.username}\n\nPassword: ${globals.password}" change_password: + - if (!${settings.custom_password:false}): + setGlobals: + custom_password: ${fn.password(min)} + else: + setGlobals: + custom_password: ${settings.custom_password} - cmd[cp]: user: root commands: - - echo "${settings.manage_username}:${globals.password}" | chpasswd + - echo "${settings.manage_username}:${globals.custom_password}" | chpasswd - echo "Password changed for ${settings.manage_username}" >> /home/jelastic/add-sftp-user-addon/logs/script_output.log - if ("${response.exitStatus}" != "0"): return: passwordChangeError @@ -167,7 +179,7 @@ responses: message: "Failed to change password for ${settings.manage_username}. Check logs for details." passwordChangeSuccess: type: success - message: "Password changed successfully for ${settings.manage_username}.\n\n New password: ${globals.password}" + message: "Password changed successfully for ${settings.manage_username}.\n\n New password: ${globals.custom_password}" deleteUserError: type: error message: "Failed to delete user ${settings.manage_username}. Check logs for details."