@@ -96,7 +96,7 @@
|
||||
name: RouteName.SEND_PASSWORD_RESET,
|
||||
params: { email: credentials.email },
|
||||
}"
|
||||
>{{ t("Forgot your password ?") }}</o-button
|
||||
>{{ t("Forgot your password?") }}</o-button
|
||||
>
|
||||
<o-button
|
||||
tag="router-link"
|
||||
@@ -145,6 +145,7 @@ import AuthProviders from "@/components/User/AuthProviders.vue";
|
||||
import RouteName from "@/router/name";
|
||||
import { LoginError, LoginErrorCode } from "@/types/enums";
|
||||
import { useCurrentUserClient } from "@/composition/apollo/user";
|
||||
import { useHead } from "@vueuse/head";
|
||||
|
||||
const props = withDefaults(
|
||||
defineProps<{
|
||||
@@ -198,7 +199,9 @@ onLoginMutationDone(async (result) => {
|
||||
router.push(redirect.value);
|
||||
return;
|
||||
}
|
||||
console.debug("No redirect, going to homepage");
|
||||
if (window.localStorage) {
|
||||
console.debug("Has localstorage, setting welcome back");
|
||||
window.localStorage.setItem("welcome-back", "yes");
|
||||
}
|
||||
router.replace({ name: RouteName.HOME });
|
||||
@@ -235,7 +238,6 @@ const { onDone: onCurrentUserMutationDone, mutate: updateCurrentUserMutation } =
|
||||
useMutation(UPDATE_CURRENT_USER_CLIENT);
|
||||
|
||||
onCurrentUserMutationDone(async () => {
|
||||
console.debug("saved current user client, now for actor client");
|
||||
try {
|
||||
await initializeCurrentActor();
|
||||
} catch (err: any) {
|
||||
@@ -252,7 +254,6 @@ onCurrentUserMutationDone(async () => {
|
||||
});
|
||||
|
||||
const setupClientUserAndActors = async (login: ILogin): Promise<void> => {
|
||||
console.debug("setuping client user and actors after login", login);
|
||||
updateCurrentUserMutation({
|
||||
id: login.user.id,
|
||||
email: credentials.email,
|
||||
@@ -276,7 +277,7 @@ const caseWarningText = computed<string | undefined>(() => {
|
||||
|
||||
const caseWarningType = computed<string | undefined>(() => {
|
||||
if (hasCaseWarning.value) {
|
||||
return "is-warning";
|
||||
return "warning";
|
||||
}
|
||||
return undefined;
|
||||
});
|
||||
@@ -306,4 +307,8 @@ onMounted(() => {
|
||||
router.push("/");
|
||||
}
|
||||
});
|
||||
|
||||
useHead({
|
||||
title: computed(() => t("Login")),
|
||||
});
|
||||
</script>
|
||||
|
||||
@@ -209,14 +209,14 @@ import RouteName from "../../router/name";
|
||||
import { IConfig } from "../../types/config.model";
|
||||
import { CONFIG } from "../../graphql/config";
|
||||
import AuthProviders from "../../components/User/AuthProviders.vue";
|
||||
import { AbsintheGraphQLError } from "../../types/apollo";
|
||||
import { computed, reactive, ref, watch } from "vue";
|
||||
import { useMutation, useQuery } from "@vue/apollo-composable";
|
||||
import { useI18n } from "vue-i18n";
|
||||
import { useRouter } from "vue-router";
|
||||
import { useHead } from "@vueuse/head";
|
||||
import { AbsintheGraphQLErrors } from "@/types/errors.model";
|
||||
|
||||
type errorType = "is-danger" | "is-warning";
|
||||
type errorType = "danger" | "warning";
|
||||
type errorMessage = { type: errorType; message: string };
|
||||
type credentialsType = { email: string; password: string; locale: string };
|
||||
|
||||
@@ -271,24 +271,25 @@ onDone(() => {
|
||||
});
|
||||
|
||||
onError((error) => {
|
||||
// @ts-ignore
|
||||
error.graphQLErrors.forEach(({ field, message }: AbsintheGraphQLError) => {
|
||||
switch (field) {
|
||||
case "email":
|
||||
emailErrors.value.push({
|
||||
type: "is-danger" as errorType,
|
||||
message: message[0] as string,
|
||||
});
|
||||
break;
|
||||
case "password":
|
||||
passwordErrors.value.push({
|
||||
type: "is-danger" as errorType,
|
||||
message: message[0] as string,
|
||||
});
|
||||
break;
|
||||
default:
|
||||
(error.graphQLErrors as AbsintheGraphQLErrors).forEach(
|
||||
({ field, message }) => {
|
||||
switch (field) {
|
||||
case "email":
|
||||
emailErrors.value.push({
|
||||
type: "danger" as errorType,
|
||||
message: message[0] as string,
|
||||
});
|
||||
break;
|
||||
case "password":
|
||||
passwordErrors.value.push({
|
||||
type: "danger" as errorType,
|
||||
message: message[0] as string,
|
||||
});
|
||||
break;
|
||||
default:
|
||||
}
|
||||
}
|
||||
});
|
||||
);
|
||||
sendingForm.value = false;
|
||||
});
|
||||
|
||||
@@ -310,10 +311,10 @@ const submit = async (): Promise<void> => {
|
||||
watch(credentials, () => {
|
||||
if (credentials.email !== credentials.email.toLowerCase()) {
|
||||
const error = {
|
||||
type: "is-warning" as errorType,
|
||||
type: "warning" as errorType,
|
||||
message: t(
|
||||
"Emails usually don't contain capitals, make sure you haven't made a typo."
|
||||
) as string,
|
||||
),
|
||||
};
|
||||
emailErrors.value = [error];
|
||||
}
|
||||
@@ -322,9 +323,9 @@ watch(credentials, () => {
|
||||
const maxErrorType = (errors: errorMessage[]): errorType | undefined => {
|
||||
if (!errors || errors.length === 0) return undefined;
|
||||
return errors.reduce<errorType>((acc, error) => {
|
||||
if (error.type === "is-danger" || acc === "is-danger") return "is-danger";
|
||||
return "is-warning";
|
||||
}, "is-warning");
|
||||
if (error.type === "danger" || acc === "danger") return "danger";
|
||||
return "warning";
|
||||
}, "warning");
|
||||
};
|
||||
|
||||
const errorEmailType = computed((): errorType | undefined => {
|
||||
|
||||
@@ -43,7 +43,7 @@
|
||||
<o-button
|
||||
v-if="stepIndex >= 2"
|
||||
variant="success"
|
||||
size="is-big"
|
||||
size="big"
|
||||
tag="router-link"
|
||||
:to="{ name: RouteName.HOME }"
|
||||
>
|
||||
|
||||
Reference in New Issue
Block a user