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') }} {{ $t('admin.APPLICATION') }}
</router-link> </router-link>
</dt> </dt>
<dd> <dd class="application-config-details">
{{ $t('admin.UPDATE_APPLICATION_DESCRIPTION') }}<br /> {{ $t('admin.UPDATE_APPLICATION_DESCRIPTION') }}<br />
<span class="registration-status"> <span class="registration-status">
{{ {{
@ -22,6 +22,13 @@
) )
}} }}
</span> </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> </dd>
<dt> <dt>
<router-link to="/admin/sports"> <router-link to="/admin/sports">
@ -82,8 +89,13 @@
dd { dd {
margin-bottom: $default-margin * 3; margin-bottom: $default-margin * 3;
} }
.registration-status { .application-config-details {
font-weight: bold; display: flex;
flex-direction: column;
.email-sending-status,
.registration-status {
font-weight: bold;
}
} }
} }
} }

View File

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

View File

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

View File

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

View File

@ -21,6 +21,7 @@
"CONFIRM_USER_PASSWORD_RESET": "Are you sure you want to reset {0} password?", "CONFIRM_USER_PASSWORD_RESET": "Are you sure you want to reset {0} password?",
"CURRENT_EMAIL": "Current email", "CURRENT_EMAIL": "Current email",
"DELETE_USER": "Delete user", "DELETE_USER": "Delete user",
"EMAIL_SENDING_DISABLED": "Email sending is disabled.",
"ENABLE_DISABLE_SPORTS": "Enable/disable sports.", "ENABLE_DISABLE_SPORTS": "Enable/disable sports.",
"NEW_EMAIL": "New email", "NEW_EMAIL": "New email",
"PASSWORD_RESET_SUCCESSFUL": "The password has been reset.", "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.", "signature expired, please log in again": "Signature expired. Please log in again.",
"successfully registered": "Successfully registered.", "successfully registered": "Successfully registered.",
"user does not exist": "User does not exist.", "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 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." "you do not have permissions": "You do not have permissions."
}, },

View File

@ -86,7 +86,8 @@
"STOPPED_SPEED_THRESHOLD": "stopped speed threshold" "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_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.", "SUCCESSFUL_UPDATE": "Your account has been updated successfully.",
"UNITS": { "UNITS": {
"LABEL": "Units for distance", "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} ?", "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", "CURRENT_EMAIL": "Adresse email actuelle",
"DELETE_USER": "Supprimer l'utilisateur", "DELETE_USER": "Supprimer l'utilisateur",
"EMAIL_SENDING_DISABLED": "L'envoi d'emails est désactivé.",
"ENABLE_DISABLE_SPORTS": "Activer/désactiver des sports.", "ENABLE_DISABLE_SPORTS": "Activer/désactiver des sports.",
"NEW_EMAIL": "Nouvelle adresse email", "NEW_EMAIL": "Nouvelle adresse email",
"PASSWORD_RESET_SUCCESSFUL": "Le mot de passe a été réinitialisé.", "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" "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_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.", "SUCCESSFUL_UPDATE": "Votre compte a été modifié avec succès.",
"TIMEZONE": "Fuseau horaire" "TIMEZONE": "Fuseau horaire"
}, },

View File

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