From 08b3ce60597804ca3db0368074db27749dfdda80 Mon Sep 17 00:00:00 2001 From: Stephane de Labrusse Date: Mon, 12 Aug 2024 12:53:25 +0200 Subject: [PATCH 1/5] fix: Handle empty remote password in create-task configuration --- imageroot/actions/create-task/20configure | 7 ++++--- .../actions/create-task/validate-input.json | 19 +++++++++++++++---- 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/imageroot/actions/create-task/20configure b/imageroot/actions/create-task/20configure index 1ecaea9..e66280f 100755 --- a/imageroot/actions/create-task/20configure +++ b/imageroot/actions/create-task/20configure @@ -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() diff --git a/imageroot/actions/create-task/validate-input.json b/imageroot/actions/create-task/validate-input.json index 42d0646..80b9451 100644 --- a/imageroot/actions/create-task/validate-input.json +++ b/imageroot/actions/create-task/validate-input.json @@ -72,10 +72,21 @@ "minLength": 1 }, "remotepassword": { - "type": "string", - "title": "Remote Password", - "description": "Password of the remote user", - "minLength": 1 + "oneOf": [ + { + "type": "string", + "title": "Remote Password", + "description": "Password of the remote user", + "minLength": 0, + "maxLength": 0 + }, + { + "type": "string", + "title": "Remote Password", + "description": "Password of the remote user", + "minLength": 1 + } + ] }, "remoteusername": { "type": "string", From 8f632dbc5b6c127454836691dc97c41eb42c9386 Mon Sep 17 00:00:00 2001 From: Stephane de Labrusse Date: Mon, 12 Aug 2024 12:53:34 +0200 Subject: [PATCH 2/5] refactor: Remove remote password from create-task configuration --- imageroot/actions/list-tasks/20read | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/imageroot/actions/list-tasks/20read b/imageroot/actions/list-tasks/20read index 4cd28aa..1874b1b 100755 --- a/imageroot/actions/list-tasks/20read +++ b/imageroot/actions/list-tasks/20read @@ -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 From d31a3a78241faf1093fd524861f6bd95db52a63e Mon Sep 17 00:00:00 2001 From: Stephane de Labrusse Date: Mon, 12 Aug 2024 12:54:06 +0200 Subject: [PATCH 3/5] feat: Add placeholder for unchanged password in create-task configuration --- ui/public/i18n/en/translation.json | 3 ++- ui/src/components/CreateOrEditTask.vue | 5 ++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/ui/public/i18n/en/translation.json b/ui/public/i18n/en/translation.json index b05fd89..4b9feae 100644 --- a/ui/public/i18n/en/translation.json +++ b/ui/public/i18n/en/translation.json @@ -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": "Leave empty to keep the current password" }, "about": { "title": "About" diff --git a/ui/src/components/CreateOrEditTask.vue b/ui/src/components/CreateOrEditTask.vue index 39f9716..aae5ef6 100644 --- a/ui/src/components/CreateOrEditTask.vue +++ b/ui/src/components/CreateOrEditTask.vue @@ -59,6 +59,9 @@ :label="$t('tasks.remotepassword')" ref="remotepassword" :invalid-message="$t(error.remotepassword)" + :placeholder=" + isEdit ? $t('tasks.unchanged_password_placeholder') : '' + " /> Date: Mon, 2 Sep 2024 18:23:06 +0200 Subject: [PATCH 4/5] translation review of Davide Principi Co-authored-by: Davide Principi --- ui/public/i18n/en/translation.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ui/public/i18n/en/translation.json b/ui/public/i18n/en/translation.json index 4b9feae..a20d70f 100644 --- a/ui/public/i18n/en/translation.json +++ b/ui/public/i18n/en/translation.json @@ -115,7 +115,7 @@ "every_minutes": "Every {num} minutes", "configure_imapsync": "Go to the settings", "STARTTLS_not_allowed_use_IMAPS": "STARTTLS is not allowed by the provider", - "unchanged_password_placeholder": "Leave empty to keep the current password" + "unchanged_password_placeholder": "Unchanged" }, "about": { "title": "About" From 520228a66c741a482887b710130b8d321f8a323f Mon Sep 17 00:00:00 2001 From: Stephane de Labrusse Date: Mon, 2 Sep 2024 18:24:45 +0200 Subject: [PATCH 5/5] no check of length for string password Co-authored-by: Davide Principi --- .../actions/create-task/validate-input.json | 18 +++--------------- 1 file changed, 3 insertions(+), 15 deletions(-) diff --git a/imageroot/actions/create-task/validate-input.json b/imageroot/actions/create-task/validate-input.json index 80b9451..e158850 100644 --- a/imageroot/actions/create-task/validate-input.json +++ b/imageroot/actions/create-task/validate-input.json @@ -72,21 +72,9 @@ "minLength": 1 }, "remotepassword": { - "oneOf": [ - { - "type": "string", - "title": "Remote Password", - "description": "Password of the remote user", - "minLength": 0, - "maxLength": 0 - }, - { - "type": "string", - "title": "Remote Password", - "description": "Password of the remote user", - "minLength": 1 - } - ] + "type": "string", + "title": "Remote Password", + "description": "Password of the remote user. If the string is empty, the password is not changed" }, "remoteusername": { "type": "string",