Skip to content

Commit

Permalink
Merge pull request #25 from NethServer/sdl-6996
Browse files Browse the repository at this point in the history
Refactor password handling and update password placeholder NethServer/dev#6996
  • Loading branch information
stephdl authored Sep 3, 2024
2 parents 4ac29ed + 520228a commit 598a194
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 12 deletions.
7 changes: 4 additions & 3 deletions imageroot/actions/create-task/20configure
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ f = open("./imapsync/"+localuser+'_'+task_id+".env", "w", encoding="utf-8")
f.write(user_env)
f.close()

f = open("./imapsync/"+localuser+'_'+task_id+".pwd", "w", encoding="utf-8")
f.write(remotepassword)
f.close()
if remotepassword != "":
f = open("./imapsync/"+localuser+'_'+task_id+".pwd", "w", encoding="utf-8")
f.write(remotepassword)
f.close()
3 changes: 1 addition & 2 deletions imageroot/actions/create-task/validate-input.json
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,7 @@
"remotepassword": {
"type": "string",
"title": "Remote Password",
"description": "Password of the remote user",
"minLength": 1
"description": "Password of the remote user. If the string is empty, the password is not changed"
},
"remoteusername": {
"type": "string",
Expand Down
7 changes: 2 additions & 5 deletions imageroot/actions/list-tasks/20read
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,8 @@ else:
elif "delete_remote" in data and data["delete_remote"] == "":
data["delete_remote"] = False

# remote password (single line)
with open('imapsync/'+task_id+'.pwd', 'r') as file:
env_lines = file.readlines()
for line in env_lines:
data['remotepassword']=line
# remote password UI must never knows it
data['remotepassword']=""
#test if service is running
service_status = True if os.path.exists("imapsync/"+task_id+".pid") else False

Expand Down
3 changes: 2 additions & 1 deletion ui/public/i18n/en/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,8 @@
"fetching_statistic_please_wait": "Waiting to retrieve statictics, please wait",
"every_minutes": "Every {num} minutes",
"configure_imapsync": "Go to the settings",
"STARTTLS_not_allowed_use_IMAPS": "STARTTLS is not allowed by the provider"
"STARTTLS_not_allowed_use_IMAPS": "STARTTLS is not allowed by the provider",
"unchanged_password_placeholder": "Unchanged"
},
"about": {
"title": "About"
Expand Down
5 changes: 4 additions & 1 deletion ui/src/components/CreateOrEditTask.vue
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@
:label="$t('tasks.remotepassword')"
ref="remotepassword"
:invalid-message="$t(error.remotepassword)"
:placeholder="
isEdit ? $t('tasks.unchanged_password_placeholder') : ''
"
/>
<NsTextInput
v-model.trim="task.remotehostname"
Expand Down Expand Up @@ -276,7 +279,7 @@ export default {
}
isValidationOk = false;
}
if (!this.task.remotepassword) {
if (!this.task.remotepassword && !this.isEdit) {
this.error.remotepassword = "common.required";

if (isValidationOk) {
Expand Down

0 comments on commit 598a194

Please sign in to comment.