Skip to content

Commit

Permalink
Merge pull request #10 from NethServer/sdl-6895-fixUI-restrictLogin
Browse files Browse the repository at this point in the history
Refactor password handling and UI updates NethServer/dev#6895
  • Loading branch information
stephdl authored May 6, 2024
2 parents b0c3dfe + a8616a5 commit 167970d
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 15 deletions.
3 changes: 2 additions & 1 deletion imageroot/actions/get-configuration/20read
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ command = "/usr/bin/podman exec mariadb-app mysql -u root -D piler -e 'SELECT pa
output = subprocess.run(command, shell=True, capture_output=True, text=True)
is_found_auditor = "$1$SLIIIS$JMBwGqQg4lIir2P2YU1y.0" in output.stdout

config['is_default_password'] = True if is_found_admin or is_found_auditor else False
config['is_default_password_admin'] = True if is_found_admin else False
config['is_default_password_auditor'] = True if is_found_auditor else False

import_running = subprocess.run(['systemctl', '--user', 'is-active', "import-email-to-piler.service"], capture_output=True, text=True)
config['import_email_is_running'] = True if import_running.stdout.strip() == 'active' else False
Expand Down
13 changes: 10 additions & 3 deletions imageroot/actions/get-configuration/validate-output.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
"http2https": true,
"lets_encrypt": true,
"mail_server": "xxxxxxxxxxxxxxxxxxxxxxxxx",
"is_default_password": false,
"is_default_password_admin": false,
"is_default_password_auditor": false,
"import_email_is_running": false
}
],
Expand All @@ -19,7 +20,8 @@
"http2https",
"lets_encrypt",
"mail_server",
"is_default_password",
"is_default_password_admin",
"is_default_password_auditor",
"import_email_is_running"
],
"properties": {
Expand All @@ -43,7 +45,12 @@
"type": "string",
"title": "Mail server UUID"
},
"is_default_password": {
"is_default_password_admin": {
"type": "boolean",
"title": "Default password",
"description": "True if the password is the default one"
},
"is_default_password_auditor": {
"type": "boolean",
"title": "Default password",
"description": "True if the password is the default one"
Expand Down
5 changes: 3 additions & 2 deletions ui/public/i18n/language.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,9 @@
"mail_server_is_not_valid": "This mail server cannot be used by Piler",
"host_pattern": "Must be a valid fully qualified domain name",
"host_format": "Must be a valid fully qualified domain name",
"password_warning": "The passwords are the default ones",
"password_warning_description": "Please change the password in the Piler webapp for admin@local(pilerrocks) and auditor@local(auditor)",
"password_warning": "Change {user} password",
"password_warning_description": "The default password \"{password}\" of \"{user}\" must be changed",
"open_piler": "Open Piler",
"import_email_is_running_warning": "Import emails is running",
"import_email_is_running_description": "Please wait until the import emails action is finished",
"import_email_to_piler": "Import emails to Piler",
Expand Down
40 changes: 31 additions & 9 deletions ui/src/views/Settings.vue
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,31 @@
/>
</cv-column>
</cv-row>
<cv-row v-if="is_default_password">
<cv-row v-if="is_default_password_admin">
<cv-column>
<NsInlineNotification
kind="warning"
:title="$t('settings.password_warning')"
:description="$t('settings.password_warning_description')"
:title="$t('settings.password_warning', {user:'admin@local'})"
:description="$t('settings.password_warning_description', {user:'admin@local', password:'pilerrocks'})"
:showCloseButton="false"
@click="goToPilerWebapp"
:actionLabel="$t('settings.open_piler')"
/>
</cv-column>
</cv-row>
<cv-row v-if="piler_is_running && ! always_bcc_correctly_set">
<cv-row v-if="is_default_password_auditor">
<cv-column>
<NsInlineNotification
kind="warning"
:title="$t('settings.password_warning', {user:'auditor@local'})"
:description="$t('settings.password_warning_description', {user:'auditor@local', password:'auditor'})"
:showCloseButton="false"
@click="goToPilerWebapp"
:actionLabel="$t('settings.open_piler')"
/>
</cv-column>
</cv-row>
<cv-row v-if="piler_is_running && !always_bcc_correctly_set">
<cv-column>
<NsInlineNotification
kind="warning"
Expand All @@ -53,13 +67,16 @@
<cv-column>
<cv-tile light>
<cv-skeleton-text
v-show="loading.getConfiguration"
v-show="loading.getConfiguration || loading.configureModule"
heading
paragraph
:line-count="10"
width="80%"
></cv-skeleton-text>
<cv-form v-show="!loading.getConfiguration" @submit.prevent="configureModule">
<cv-form
v-show="!loading.getConfiguration && !loading.configureModule"
@submit.prevent="configureModule"
>
<NsTextInput
:label="$t('settings.piler_fqdn')"
:placeholder="$t('settings.placeholder_piler_domain')"
Expand Down Expand Up @@ -189,7 +206,8 @@ export default {
import_email_is_running: false,
piler_is_running: false,
always_bcc_correctly_set: false,
is_default_password: false,
is_default_password_admin: false,
is_default_password_auditor: false,
isLetsEncryptEnabled: false,
isHttpToHttpsEnabled: false,
loading: {
Expand Down Expand Up @@ -225,6 +243,9 @@ export default {
next();
},
methods: {
goToPilerWebapp() {
window.open(`https://${this.host}`, "_blank");
},
async getConfiguration() {
this.loading.getConfiguration = true;
this.error.getConfiguration = "";
Expand Down Expand Up @@ -277,7 +298,8 @@ export default {
this.mail_server = config.mail_server;
});
this.mail_server_URL = config.mail_server_URL;
this.is_default_password = config.is_default_password;
this.is_default_password_admin = config.is_default_password_admin;
this.is_default_password_auditor = config.is_default_password_auditor;
this.import_email_is_running = config.import_email_is_running;
this.piler_is_running = config.piler_is_running;
this.always_bcc_correctly_set = config.always_bcc_correctly_set;
Expand Down Expand Up @@ -383,9 +405,9 @@ export default {
this.loading.configureModule = false;
},
configureModuleCompleted() {
this.loading.configureModule = false;
// reload configuration
this.getConfiguration();
this.loading.configureModule = false;
},
},
};
Expand Down

0 comments on commit 167970d

Please sign in to comment.