Appearance improvements, update of endpoints, and implementation of .well-known for checking API URL #3
3 changed files with 40 additions and 3 deletions
|
@ -15,13 +15,15 @@
|
||||||
<button type="submit">Login</button>
|
<button type="submit">Login</button>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
<div>
|
<div v-if="registrationEnabled">
|
||||||
Don't have an account? <NuxtLink :href="registerUrl">Register</NuxtLink> one!
|
Don't have an account? <NuxtLink :href="registerUrl">Register</NuxtLink> one!
|
||||||
</div>
|
</div>
|
||||||
</NuxtLayout>
|
</NuxtLayout>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
|
import type { StatsResponse } from '~/types/interfaces';
|
||||||
|
|
||||||
|
|
||||||
definePageMeta({
|
definePageMeta({
|
||||||
layout: "auth"
|
layout: "auth"
|
||||||
|
@ -36,6 +38,18 @@ const form = reactive({
|
||||||
|
|
||||||
const query = useRoute().query as Record<string, string>;
|
const query = useRoute().query as Record<string, string>;
|
||||||
const searchParams = new URLSearchParams(query);
|
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 registerUrl = `/register?${searchParams}`
|
||||||
|
|
||||||
const { login } = useAuth();
|
const { login } = useAuth();
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
<template>
|
<template>
|
||||||
<NuxtLayout>
|
<NuxtLayout>
|
||||||
<form @submit="register">
|
<form v-if="registrationEnabled" @submit="register">
|
||||||
<div>
|
<div>
|
||||||
<!--
|
<!--
|
||||||
<span class="form-error" v-if="errors.username.length > 0">
|
<span class="form-error" v-if="errors.username.length > 0">
|
||||||
|
@ -32,6 +32,9 @@
|
||||||
<button type="submit">Register</button>
|
<button type="submit">Register</button>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
|
<div v-else>
|
||||||
|
<h3>This instance has disabled registration.</h3>
|
||||||
|
</div>
|
||||||
<div>
|
<div>
|
||||||
Already have an account? <NuxtLink :href="loginUrl">Log in</NuxtLink>!
|
Already have an account? <NuxtLink :href="loginUrl">Log in</NuxtLink>!
|
||||||
</div>
|
</div>
|
||||||
|
@ -39,11 +42,22 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
|
import type { StatsResponse } from '~/types/interfaces';
|
||||||
definePageMeta({
|
definePageMeta({
|
||||||
layout: "auth"
|
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({
|
const form = reactive({
|
||||||
username: "",
|
username: "",
|
||||||
email: "",
|
email: "",
|
||||||
|
|
|
@ -53,3 +53,12 @@ export interface UserResponse {
|
||||||
email?: string,
|
email?: string,
|
||||||
email_verified?: boolean
|
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