Disabling account e-mail fields if e-mail service is disabled (verification e-mail couldn't be sent).
This commit is contained in:
@@ -11,6 +11,8 @@ import { patch, post } from '#/src/api.js';
|
|||||||
const pageContext = inject('pageContext');
|
const pageContext = inject('pageContext');
|
||||||
const { user } = pageContext;
|
const { user } = pageContext;
|
||||||
|
|
||||||
|
const allowEmailUpdate = pageContext.env.emailEnabled;
|
||||||
|
|
||||||
const credentials = reactive({
|
const credentials = reactive({
|
||||||
email: null,
|
email: null,
|
||||||
password: null,
|
password: null,
|
||||||
@@ -95,7 +97,7 @@ async function verifyEmail() {
|
|||||||
|
|
||||||
<template #popper>
|
<template #popper>
|
||||||
<div class="unverified-tooltip">
|
<div class="unverified-tooltip">
|
||||||
Your e-mail address is unverified
|
Your e-mail address is unverified.
|
||||||
|
|
||||||
<Ellipsis v-if="verifying" />
|
<Ellipsis v-if="verifying" />
|
||||||
|
|
||||||
@@ -105,11 +107,13 @@ async function verifyEmail() {
|
|||||||
>Verification e-mail sent</strong>
|
>Verification e-mail sent</strong>
|
||||||
|
|
||||||
<button
|
<button
|
||||||
v-else
|
v-else-if="allowEmailUpdate"
|
||||||
type="button"
|
type="button"
|
||||||
class="button button-primary"
|
class="button button-primary"
|
||||||
@click="verifyEmail"
|
@click="verifyEmail"
|
||||||
>Verify now</button>
|
>Verify now</button>
|
||||||
|
|
||||||
|
<span v-else>Verification is currently unavailable.</span>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
</VDropdown>
|
</VDropdown>
|
||||||
@@ -123,6 +127,7 @@ async function verifyEmail() {
|
|||||||
</span>
|
</span>
|
||||||
|
|
||||||
<input
|
<input
|
||||||
|
v-if="allowEmailUpdate"
|
||||||
v-model="credentials.email"
|
v-model="credentials.email"
|
||||||
type="email"
|
type="email"
|
||||||
placeholder="New e-mail"
|
placeholder="New e-mail"
|
||||||
|
|||||||
@@ -9,6 +9,10 @@ import navigate from '#/src/navigate.js';
|
|||||||
const pageContext = inject('pageContext');
|
const pageContext = inject('pageContext');
|
||||||
const user = pageContext.user;
|
const user = pageContext.user;
|
||||||
const allowSignup = pageContext.env.allowSignup;
|
const allowSignup = pageContext.env.allowSignup;
|
||||||
|
// const allowRecovery = pageContext.env.emailEnabled;
|
||||||
|
const allowRecovery = false; // TODO: implement
|
||||||
|
|
||||||
|
console.log(pageContext.env);
|
||||||
|
|
||||||
const username = ref('');
|
const username = ref('');
|
||||||
const password = ref('');
|
const password = ref('');
|
||||||
@@ -104,6 +108,12 @@ onMounted(() => {
|
|||||||
href="/signup"
|
href="/signup"
|
||||||
class="link"
|
class="link"
|
||||||
>Create an account</a>
|
>Create an account</a>
|
||||||
|
|
||||||
|
<a
|
||||||
|
v-if="allowRecovery"
|
||||||
|
href="/recovery"
|
||||||
|
class="link"
|
||||||
|
>I forgot my password</a>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
@@ -91,6 +91,10 @@ async function hashPassword(password) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export async function sendEmailVerification(user, customEmail, trigger) {
|
export async function sendEmailVerification(user, customEmail, trigger) {
|
||||||
|
if (!config.email.enabled) {
|
||||||
|
throw new HttpError('E-mail verification is disabled', 503);
|
||||||
|
}
|
||||||
|
|
||||||
if (!user) {
|
if (!user) {
|
||||||
throw new HttpError('No user provided', 401);
|
throw new HttpError('No user provided', 401);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user