feat: implement checking if email verification is enabled or not, change appearance of auth
All checks were successful
ci/woodpecker/push/build-and-publish Pipeline was successful
All checks were successful
ci/woodpecker/push/build-and-publish Pipeline was successful
This commit is contained in:
parent
47d5063bb7
commit
f39ff00b3b
3 changed files with 40 additions and 3 deletions
|
@ -15,13 +15,15 @@
|
|||
<button type="submit">Login</button>
|
||||
</div>
|
||||
</form>
|
||||
<div>
|
||||
<div v-if="registrationEnabled">
|
||||
Don't have an account? <NuxtLink :href="registerUrl">Register</NuxtLink> one!
|
||||
</div>
|
||||
</NuxtLayout>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import type { StatsResponse } from '~/types/interfaces';
|
||||
|
||||
|
||||
definePageMeta({
|
||||
layout: "auth"
|
||||
|
@ -36,6 +38,18 @@ const form = reactive({
|
|||
|
||||
const query = useRoute().query as Record<string, string>;
|
||||
const searchParams = new URLSearchParams(query);
|
||||
|
||||
const instanceUrl = useCookie("instance_url").value;
|
||||
const registrationEnabled = ref<boolean>(true);
|
||||
|
||||
if (instanceUrl) {
|
||||
const statsUrl = new URL("/stats", instanceUrl).href;
|
||||
const { status, data } = await useFetch<StatsResponse>(statsUrl);
|
||||
if (status.value == "success" && data.value) {
|
||||
registrationEnabled.value = data.value.registration_enabled;
|
||||
}
|
||||
}
|
||||
|
||||
const registerUrl = `/register?${searchParams}`
|
||||
|
||||
const { login } = useAuth();
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<template>
|
||||
<NuxtLayout>
|
||||
<form @submit="register">
|
||||
<form v-if="registrationEnabled" @submit="register">
|
||||
<div>
|
||||
<!--
|
||||
<span class="form-error" v-if="errors.username.length > 0">
|
||||
|
@ -32,6 +32,9 @@
|
|||
<button type="submit">Register</button>
|
||||
</div>
|
||||
</form>
|
||||
<div v-else>
|
||||
<h3>This instance has disabled registration.</h3>
|
||||
</div>
|
||||
<div>
|
||||
Already have an account? <NuxtLink :href="loginUrl">Log in</NuxtLink>!
|
||||
</div>
|
||||
|
@ -39,11 +42,22 @@
|
|||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
|
||||
import type { StatsResponse } from '~/types/interfaces';
|
||||
definePageMeta({
|
||||
layout: "auth"
|
||||
})
|
||||
|
||||
const instanceUrl = useCookie("instance_url").value;
|
||||
const registrationEnabled = ref<boolean>(false);
|
||||
|
||||
if (instanceUrl) {
|
||||
const statsUrl = new URL("/stats", instanceUrl).href;
|
||||
const { status, data, error } = await useFetch<StatsResponse>(statsUrl);
|
||||
if (status.value == "success" && data.value) {
|
||||
registrationEnabled.value = data.value.registration_enabled;
|
||||
}
|
||||
}
|
||||
|
||||
const form = reactive({
|
||||
username: "",
|
||||
email: "",
|
||||
|
|
|
@ -53,3 +53,12 @@ export interface UserResponse {
|
|||
email?: string,
|
||||
email_verified?: boolean
|
||||
}
|
||||
|
||||
export interface StatsResponse {
|
||||
accounts: number,
|
||||
uptime: number,
|
||||
version: string,
|
||||
registration_enabled: boolean,
|
||||
email_verification_required: boolean,
|
||||
build_number: string
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue