Added User Password change and Delete
parent
55ce428998
commit
a0e18eb3e7
65
manifest.jps
65
manifest.jps
|
@ -18,6 +18,14 @@ settings:
|
||||||
name: enable_ssh
|
name: enable_ssh
|
||||||
caption: Also enable SSH access
|
caption: Also enable SSH access
|
||||||
default: false
|
default: false
|
||||||
|
manageUserForm:
|
||||||
|
fields:
|
||||||
|
- type: string
|
||||||
|
inputType: text
|
||||||
|
name: manage_username
|
||||||
|
caption: Username to Manage
|
||||||
|
description: "Input the username you want to manage."
|
||||||
|
required: true
|
||||||
|
|
||||||
globals:
|
globals:
|
||||||
username: "user${fn.random(10000,99999)}"
|
username: "user${fn.random(10000,99999)}"
|
||||||
|
@ -55,21 +63,25 @@ actions:
|
||||||
user: root
|
user: root
|
||||||
- if ("${response.exitStatus}" != "0"):
|
- if ("${response.exitStatus}" != "0"):
|
||||||
return: sftpError
|
return: sftpError
|
||||||
- return {
|
- return: sftpSuccess
|
||||||
'result': 'success',
|
change_password:
|
||||||
'message': 'Connection Details\n\n' +
|
- cmd[cp]:
|
||||||
'SFTP Host: ' + '${globals.sftpHost}' + '\n\n' +
|
commands:
|
||||||
'Port: ' + '${globals.sftpPort}' + '\n\n\n' +
|
- echo "${settings.manage_username}:${globals.password}" | chpasswd
|
||||||
'Login Credentials\n\n' +
|
- echo "Password changed for ${settings.manage_username}" >> /home/jelastic/add-sftp-user-addon/logs/script_output.log
|
||||||
'Username: ' + '${globals.username}' + '\n\n' +
|
user: root
|
||||||
'Password: ' + '${globals.password}',
|
- if ("${response.exitStatus}" != "0"):
|
||||||
'email': 'Connection Details' +
|
return: passwordChangeError
|
||||||
'SFTP Host: ' + '${globals.sftpHost}' + '\n' +
|
- return: passwordChangeSuccess
|
||||||
'Port: ' + '${globals.sftpPort}' + '\n\n' +
|
delete_user:
|
||||||
'Login Credentials' +
|
- cmd[cp]:
|
||||||
'Username: ' + '${globals.username}' + '\n' +
|
commands:
|
||||||
'Password: ' + '${globals.password}'
|
- userdel ${settings.manage_username}
|
||||||
}
|
- echo "User ${settings.manage_username} deleted" >> /home/jelastic/add-sftp-user-addon/logs/script_output.log
|
||||||
|
user: root
|
||||||
|
- if ("${response.exitStatus}" != "0"):
|
||||||
|
return: deleteUserError
|
||||||
|
- return: deleteUserSuccess
|
||||||
|
|
||||||
responses:
|
responses:
|
||||||
installSuccess:
|
installSuccess:
|
||||||
|
@ -78,9 +90,32 @@ responses:
|
||||||
sftpError:
|
sftpError:
|
||||||
type: error
|
type: error
|
||||||
message: "Failed to add SFTP user. Please check the server logs for more details."
|
message: "Failed to add SFTP user. Please check the server logs for more details."
|
||||||
|
sftpSuccess:
|
||||||
|
type: success
|
||||||
|
message: "Connection Details\n\nSFTP Host: ${globals.sftpHost}\n\nPort: ${globals.sftpPort}\n\nLogin Credentials\n\nUsername: ${globals.username}\n\nPassword: ${globals.password}"
|
||||||
|
passwordChangeError:
|
||||||
|
type: error
|
||||||
|
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}"
|
||||||
|
deleteUserError:
|
||||||
|
type: error
|
||||||
|
message: "Failed to delete user ${settings.manage_username}. Check logs for details."
|
||||||
|
deleteUserSuccess:
|
||||||
|
type: success
|
||||||
|
message: "User ${settings.manage_username} deleted successfully."
|
||||||
|
|
||||||
buttons:
|
buttons:
|
||||||
- settings: sfpform
|
- settings: sfpform
|
||||||
action: add_sftp_user
|
action: add_sftp_user
|
||||||
caption: Add SFTP/SSH User
|
caption: Add SFTP/SSH User
|
||||||
confirmText: "Are you sure you want to add this SFTP user?"
|
confirmText: "Are you sure you want to add this SFTP user?"
|
||||||
|
- settings: manageUserForm
|
||||||
|
action: change_password
|
||||||
|
caption: Change Password
|
||||||
|
confirmText: "Are you sure you want to change the password for this user?"
|
||||||
|
- settings: manageUserForm
|
||||||
|
action: delete_user
|
||||||
|
caption: Delete User
|
||||||
|
confirmText: "Are you sure you want to delete this user?"
|
Loading…
Reference in New Issue