Client - hide emails related infos when email sending is disabled

This commit is contained in:
Sam 2022-04-23 19:30:54 +02:00
parent 848cc492fd
commit fab9c00726
10 changed files with 73 additions and 14 deletions

View File

@ -11,7 +11,7 @@
{{ $t('admin.APPLICATION') }}
</router-link>
</dt>
<dd>
<dd class="application-config-details">
{{ $t('admin.UPDATE_APPLICATION_DESCRIPTION') }}<br />
<span class="registration-status">
{{
@ -22,6 +22,13 @@
)
}}
</span>
<span
class="email-sending-status"
v-if="!appConfig.is_email_sending_enabled"
>
<i class="fa fa-exclamation-triangle" aria-hidden="true" />
{{ $t('admin.EMAIL_SENDING_DISABLED') }}
</span>
</dd>
<dt>
<router-link to="/admin/sports">
@ -82,8 +89,13 @@
dd {
margin-bottom: $default-margin * 3;
}
.registration-status {
font-weight: bold;
.application-config-details {
display: flex;
flex-direction: column;
.email-sending-status,
.registration-status {
font-weight: bold;
}
}
}
}

View File

@ -93,7 +93,10 @@
{{ $t('admin.UPDATE_USER_EMAIL') }}
</button>
<button
v-if="authUser.username !== user.username"
v-if="
authUser.username !== user.username &&
appConfig.is_email_sending_enabled
"
@click.prevent="updateDisplayModal('reset')"
>
{{ $t('admin.RESET_USER_PASSWORD') }}
@ -124,6 +127,7 @@
} from 'vue'
import { AUTH_USER_STORE, ROOT_STORE, USERS_STORE } from '@/store/constants'
import { TAppConfig } from '@/types/application'
import { IAuthUserProfile, IUserProfile } from '@/types/user'
import { useStore } from '@/use/useStore'
@ -157,6 +161,9 @@
const errorMessages: ComputedRef<string | string[] | null> = computed(
() => store.getters[ROOT_STORE.GETTERS.ERROR_MESSAGES]
)
const appConfig: ComputedRef<TAppConfig> = computed(
() => store.getters[ROOT_STORE.GETTERS.APP_CONFIG]
)
let displayModal: Ref<string> = ref('')
const formErrors = ref(false)
const displayUserEmailForm: Ref<boolean> = ref(false)

View File

@ -10,7 +10,13 @@
<div class="profile-form form-box">
<ErrorMessage :message="errorMessages" v-if="errorMessages" />
<div class="info-box success-message" v-if="isSuccess">
{{ $t(`user.PROFILE.SUCCESSFUL_${emailUpdate ? 'EMAIL_' : ''}UPDATE`) }}
{{
$t(
`user.PROFILE.SUCCESSFUL_${
emailUpdate && appConfig.is_email_sending_enabled ? 'EMAIL_' : ''
}UPDATE`
)
}}
</div>
<form :class="{ errors: formErrors }" @submit.prevent="updateProfile">
<label class="form-items" for="email">
@ -77,6 +83,7 @@
import PasswordInput from '@/components/Common/PasswordInput.vue'
import { AUTH_USER_STORE, ROOT_STORE } from '@/store/constants'
import { TAppConfig } from '@/types/application'
import { IUserProfile, IUserAccountPayload } from '@/types/user'
import { useStore } from '@/use/useStore'
@ -95,6 +102,9 @@
const loading = computed(
() => store.getters[AUTH_USER_STORE.GETTERS.USER_LOADING]
)
const appConfig: ComputedRef<TAppConfig> = computed(
() => store.getters[ROOT_STORE.GETTERS.APP_CONFIG]
)
const isSuccess: ComputedRef<boolean> = computed(
() => store.getters[AUTH_USER_STORE.GETTERS.IS_SUCCESS]
)

View File

@ -16,6 +16,10 @@
message="user.REGISTER_DISABLED"
v-if="registration_disabled"
/>
<AlertMessage
message="admin.EMAIL_SENDING_DISABLED"
v-if="sendingEmailDisabled"
/>
<div
class="info-box success-message"
v-if="isSuccess || isRegistrationSuccess"
@ -23,7 +27,11 @@
{{
$t(
`user.PROFILE.SUCCESSFUL_${
isRegistrationSuccess ? 'REGISTRATION' : 'UPDATE'
isRegistrationSuccess
? `REGISTRATION${
appConfig.is_email_sending_enabled ? '_WITH_EMAIL' : ''
}`
: 'UPDATE'
}`
)
}}
@ -52,7 +60,7 @@
<input
v-if="action !== 'reset'"
id="email"
:disabled="registration_disabled"
:disabled="registration_disabled || sendingEmailDisabled"
required
@invalid="invalidateForm"
type="email"
@ -91,7 +99,10 @@
@passwordError="invalidateForm"
/>
</div>
<button type="submit" :disabled="registration_disabled">
<button
type="submit"
:disabled="registration_disabled || sendingEmailDisabled"
>
{{ $t(buttonText) }}
</button>
</form>
@ -99,8 +110,12 @@
<router-link class="links" to="/register">
{{ $t('user.REGISTER') }}
</router-link>
-
<router-link class="links" to="/password-reset/request">
<span v-if="appConfig.is_email_sending_enabled">-</span>
<router-link
v-if="appConfig.is_email_sending_enabled"
class="links"
to="/password-reset/request"
>
{{ $t('user.PASSWORD_FORGOTTEN') }}
</router-link>
</div>
@ -110,7 +125,12 @@
{{ $t('user.LOGIN') }}
</router-link>
</div>
<div v-if="['login', 'register'].includes(action)">
<div
v-if="
['login', 'register'].includes(action) &&
appConfig.is_email_sending_enabled
"
>
<router-link class="links" to="/account-confirmation/resend">
{{ $t('user.ACCOUNT_CONFIRMATION_NOT_RECEIVED') }}
</router-link>
@ -175,6 +195,11 @@
() =>
props.action === 'register' && !appConfig.value.is_registration_enabled
)
const sendingEmailDisabled: ComputedRef<boolean> = computed(
() =>
['reset-request', 'account-confirmation-resend'].includes(props.action) &&
!appConfig.value.is_email_sending_enabled
)
const formErrors = ref(false)
function getButtonText(action: string): string {

View File

@ -21,6 +21,7 @@
"CONFIRM_USER_PASSWORD_RESET": "Are you sure you want to reset {0} password?",
"CURRENT_EMAIL": "Current email",
"DELETE_USER": "Delete user",
"EMAIL_SENDING_DISABLED": "Email sending is disabled.",
"ENABLE_DISABLE_SPORTS": "Enable/disable sports.",
"NEW_EMAIL": "New email",
"PASSWORD_RESET_SUCCESSFUL": "The password has been reset.",

View File

@ -23,7 +23,7 @@
"signature expired, please log in again": "Signature expired. Please log in again.",
"successfully registered": "Successfully registered.",
"user does not exist": "User does not exist.",
"valid email must be provided for admin contact": "A valid email must be provided for admininstrator contact",
"valid email must be provided for admin contact": "A valid email must be provided for administrator contact",
"you can not delete your account, no other user has admin rights": "You can not delete your account, no other user has admin rights.",
"you do not have permissions": "You do not have permissions."
},

View File

@ -86,7 +86,8 @@
"STOPPED_SPEED_THRESHOLD": "stopped speed threshold"
},
"SUCCESSFUL_EMAIL_UPDATE": "Your account has been updated successfully. Please check your email to confirm your new email address.",
"SUCCESSFUL_REGISTRATION": "A link to activate your account has been emailed to the address provided.",
"SUCCESSFUL_REGISTRATION": "Your account has been created successfully.",
"SUCCESSFUL_REGISTRATION_WITH_EMAIL": "A link to activate your account has been emailed to the address provided.",
"SUCCESSFUL_UPDATE": "Your account has been updated successfully.",
"UNITS": {
"LABEL": "Units for distance",

View File

@ -21,6 +21,7 @@
"CONFIRM_USER_PASSWORD_RESET": "Êtes-vous sûr de vouloir réinitialiser le mot de passe de l'utilisateur {0} ?",
"CURRENT_EMAIL": "Adresse email actuelle",
"DELETE_USER": "Supprimer l'utilisateur",
"EMAIL_SENDING_DISABLED": "L'envoi d'emails est désactivé.",
"ENABLE_DISABLE_SPORTS": "Activer/désactiver des sports.",
"NEW_EMAIL": "Nouvelle adresse email",
"PASSWORD_RESET_SUCCESSFUL": "Le mot de passe a été réinitialisé.",

View File

@ -91,7 +91,8 @@
"STOPPED_SPEED_THRESHOLD": "seuil de vitesse arrêtée"
},
"SUCCESSFUL_EMAIL_UPDATE": "Votre compte a été modifié avec succès. Veuillez vérifier votre boite email pour valider votre nouvelle adresse email.",
"SUCCESSFUL_REGISTRATION": "Un lien pour activer votre compte a été envoyé à l'adresse email fournie.",
"SUCCESSFUL_REGISTRATION": "Votre compte a été créé avec succès.",
"SUCCESSFUL_REGISTRATION_WITH_EMAIL": "Un lien pour activer votre compte a été envoyé à l'adresse email fournie.",
"SUCCESSFUL_UPDATE": "Votre compte a été modifié avec succès.",
"TIMEZONE": "Fuseau horaire"
},

View File

@ -9,6 +9,7 @@ export type TAppConfig = {
[key: string]: number | boolean | string
admin_contact: string
gpx_limit_import: number
is_email_sending_enabled: boolean
is_registration_enabled: boolean
map_attribution: string
max_single_file_size: number