Merge remote-tracking branch 'origin/main' into sort-members-list
This commit is contained in:
parent
8ffe3aa738
commit
771c0699a7
9 changed files with 186 additions and 7 deletions
|
@ -23,3 +23,17 @@ steps:
|
|||
when:
|
||||
- branch: main
|
||||
event: push
|
||||
|
||||
- name: container-build-and-publish (staging)
|
||||
image: docker
|
||||
commands:
|
||||
- docker login --username radical --password $PASSWORD git.gorb.app
|
||||
- docker buildx build --platform linux/amd64,linux/arm64 --rm --push -t git.gorb.app/gorb/frontend:staging .
|
||||
environment:
|
||||
PASSWORD:
|
||||
from_secret: docker_password
|
||||
volumes:
|
||||
- /var/run/podman/podman.sock:/var/run/docker.sock
|
||||
when:
|
||||
- branch: staging
|
||||
event: push
|
||||
|
|
|
@ -1,14 +1,14 @@
|
|||
<template>
|
||||
<div @click="props.callback()" class="button" :class="props.variant + '-button'">
|
||||
<button @click="props.callback ? props.callback() : null" class="button" :class="props.variant + '-button'">
|
||||
{{ props.text }}
|
||||
</div>
|
||||
</button>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
|
||||
const props = defineProps<{
|
||||
text: string,
|
||||
callback: CallableFunction,
|
||||
callback?: CallableFunction,
|
||||
variant?: "normal" | "scary" | "neutral",
|
||||
}>();
|
||||
|
||||
|
@ -28,6 +28,8 @@ const props = defineProps<{
|
|||
border-radius: 0.7rem;
|
||||
text-decoration: none;
|
||||
display: inline-block;
|
||||
|
||||
border: none;
|
||||
}
|
||||
|
||||
.button:hover {
|
||||
|
|
|
@ -86,6 +86,14 @@ export const useApi = () => {
|
|||
await fetchWithApi("/auth/verify-email", { method: "POST", body: { email } });
|
||||
}
|
||||
|
||||
async function sendPasswordResetEmail(identifier: string): Promise<void> {
|
||||
await fetchWithApi("/auth/reset-password", { method: "GET", query: { identifier } });
|
||||
}
|
||||
|
||||
async function resetPassword(password: string, token: string) {
|
||||
await fetchWithApi("/auth/reset-password", { method: "POST", body: { password, token } });
|
||||
}
|
||||
|
||||
return {
|
||||
fetchGuilds,
|
||||
fetchGuild,
|
||||
|
@ -105,6 +113,8 @@ export const useApi = () => {
|
|||
joinGuild,
|
||||
createChannel,
|
||||
fetchInstanceStats,
|
||||
sendVerificationEmail
|
||||
sendVerificationEmail,
|
||||
sendPasswordResetEmail,
|
||||
resetPassword
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
</div>
|
||||
<div v-else id="auth-form-container">
|
||||
<slot />
|
||||
<div v-if="!['/recover', '/reset-password'].includes(route.path)">Forgot password? Recover <NuxtLink href="/recover">here</NuxtLink>!</div>
|
||||
</div>
|
||||
<div v-if="instanceUrl">
|
||||
Instance URL is set to <span style="color: var(--primary-color);">{{ instanceUrl }}</span>
|
||||
|
@ -36,7 +37,11 @@ const apiVersion = useRuntimeConfig().public.apiVersion;
|
|||
const apiBase = useCookie("api_base");
|
||||
const registrationEnabled = useState("registrationEnabled", () => true);
|
||||
|
||||
const auth = useAuth();
|
||||
const route = useRoute();
|
||||
|
||||
const query = route.query as Record<string, string>;
|
||||
const searchParams = new URLSearchParams(query);
|
||||
searchParams.delete("token");
|
||||
|
||||
onMounted(async () => {
|
||||
instanceUrl.value = useCookie("instance_url").value;
|
||||
|
@ -111,6 +116,7 @@ const form = reactive({
|
|||
#auth-form-container form {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
text-align: left;
|
||||
margin-top: 10dvh;
|
||||
gap: 1em;
|
||||
|
|
|
@ -16,7 +16,7 @@ export default defineNuxtRouteMiddleware(async (to, from) => {
|
|||
}
|
||||
}
|
||||
|
||||
if (["/login", "/register"].includes(to.path) && !Object.keys(to.query).includes("special")) {
|
||||
if (["/login", "/register", "/recover", "/reset-password"].includes(to.path) && !Object.keys(to.query).includes("special")) {
|
||||
console.log("path is login or register");
|
||||
const apiBase = useCookie("api_base");
|
||||
console.log("apiBase gotten:", apiBase.value);
|
||||
|
|
|
@ -36,6 +36,7 @@ const form = reactive({
|
|||
|
||||
const query = useRoute().query as Record<string, string>;
|
||||
const searchParams = new URLSearchParams(query);
|
||||
searchParams.delete("token");
|
||||
|
||||
const registrationEnabled = ref<boolean>(true);
|
||||
const apiBase = useCookie("api_base");
|
||||
|
@ -48,7 +49,7 @@ if (apiBase.value) {
|
|||
}
|
||||
}
|
||||
|
||||
const registerUrl = `/register?${searchParams}`
|
||||
const registerUrl = `/register?${searchParams}`;
|
||||
|
||||
const { login } = useAuth();
|
||||
|
||||
|
|
89
pages/recover.vue
Normal file
89
pages/recover.vue
Normal file
|
@ -0,0 +1,89 @@
|
|||
<template>
|
||||
<NuxtLayout name="auth">
|
||||
<div v-if="errorValue">{{ errorValue }}</div>
|
||||
<form v-if="!emailFormSent" @submit.prevent="sendEmail">
|
||||
<div>
|
||||
<label for="identifier">Email or username</label>
|
||||
<br>
|
||||
<input type="text" name="identifier" id="identifier" v-model="emailForm.identifier">
|
||||
</div>
|
||||
<div>
|
||||
<Button type="submit" text="Send email" variant="normal" />
|
||||
</div>
|
||||
</form>
|
||||
<div v-else>
|
||||
If an account with that username or email exists, an email will be sent to it shortly.
|
||||
</div>
|
||||
<div v-if="registrationEnabled">
|
||||
Don't have an account? <NuxtLink :href="registerUrl">Register</NuxtLink> one!
|
||||
</div>
|
||||
<div>
|
||||
Already have an account? <NuxtLink :href="loginUrl">Log in</NuxtLink>!
|
||||
</div>
|
||||
</NuxtLayout>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import Button from '~/components/UserInterface/Button.vue';
|
||||
|
||||
const emailForm = reactive({
|
||||
identifier: ""
|
||||
});
|
||||
|
||||
const emailFormSent = ref(false);
|
||||
|
||||
const passwordForm = reactive({
|
||||
password: ""
|
||||
});
|
||||
|
||||
const errorValue = ref<string>();
|
||||
|
||||
const registrationEnabled = ref<boolean>(true);
|
||||
const apiBase = useCookie("api_base");
|
||||
|
||||
const query = useRoute().query as Record<string, string>;
|
||||
const searchParams = new URLSearchParams(query);
|
||||
|
||||
const token = ref(searchParams.get("token"))
|
||||
searchParams.delete("token");
|
||||
const { resetPassword } = useApi();
|
||||
|
||||
const registerUrl = `/register?${searchParams}`;
|
||||
const loginUrl = `/login?${searchParams}`;
|
||||
|
||||
if (apiBase.value) {
|
||||
console.log("apiBase:", apiBase.value);
|
||||
const stats = await useApi().fetchInstanceStats(apiBase.value);
|
||||
if (stats) {
|
||||
registrationEnabled.value = stats.registration_enabled;
|
||||
}
|
||||
}
|
||||
|
||||
const { sendPasswordResetEmail } = useApi();
|
||||
|
||||
async function sendEmail() {
|
||||
try {
|
||||
await sendPasswordResetEmail(emailForm.identifier);
|
||||
emailFormSent.value = true;
|
||||
} catch (error) {
|
||||
errorValue.value = (error as any).toString();
|
||||
}
|
||||
}
|
||||
|
||||
async function sendPassword() {
|
||||
try {
|
||||
console.log("pass:", passwordForm.password);
|
||||
const hashedPass = await hashPassword(passwordForm.password)
|
||||
console.log("hashed pass:", hashedPass);
|
||||
await resetPassword(hashedPass, token.value!);
|
||||
return await navigateTo(`/login?${searchParams}`);
|
||||
} catch (error) {
|
||||
errorValue.value = (error as any).toString();
|
||||
}
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
<style>
|
||||
|
||||
</style>
|
|
@ -86,6 +86,7 @@ const auth = useAuth();
|
|||
const loggedIn = ref(await auth.getUser());
|
||||
|
||||
const query = new URLSearchParams(useRoute().query as Record<string, string>);
|
||||
query.delete("token");
|
||||
|
||||
const user = await useAuth().getUser();
|
||||
|
||||
|
|
56
pages/reset-password.vue
Normal file
56
pages/reset-password.vue
Normal file
|
@ -0,0 +1,56 @@
|
|||
<template>
|
||||
<NuxtLayout name="auth">
|
||||
<div v-if="errorValue">{{ errorValue }}</div>
|
||||
<form @submit.prevent="sendPassword">
|
||||
<div>
|
||||
<label for="password">Password</label>
|
||||
<br>
|
||||
<input type="password" name="password" id="password" v-model="passwordForm.password">
|
||||
</div>
|
||||
<div>
|
||||
<Button type="submit" text="Submit" variant="normal" />
|
||||
</div>
|
||||
</form>
|
||||
<div>
|
||||
Already have an account? <NuxtLink :href="loginUrl">Log in</NuxtLink>!
|
||||
</div>
|
||||
</NuxtLayout>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import Button from '~/components/UserInterface/Button.vue';
|
||||
|
||||
const query = useRoute().query as Record<string, string>;
|
||||
const searchParams = new URLSearchParams(query);
|
||||
|
||||
const loginUrl = `/login?${searchParams}`;
|
||||
|
||||
const token = ref(searchParams.get("token"))
|
||||
|
||||
if (!token.value) await navigateTo("/login");
|
||||
|
||||
const passwordForm = reactive({
|
||||
password: ""
|
||||
});
|
||||
|
||||
const errorValue = ref<string>();
|
||||
|
||||
const { resetPassword } = useApi();
|
||||
|
||||
async function sendPassword() {
|
||||
try {
|
||||
console.log("pass:", passwordForm.password);
|
||||
const hashedPass = await hashPassword(passwordForm.password)
|
||||
console.log("hashed pass:", hashedPass);
|
||||
await resetPassword(hashedPass, token.value!);
|
||||
return await navigateTo("/login?");
|
||||
} catch (error) {
|
||||
errorValue.value = (error as any).toString();
|
||||
}
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
<style>
|
||||
|
||||
</style>
|
Loading…
Add table
Add a link
Reference in a new issue