fix(EmailTokenVerifikation): fixed the bug where the verification was working but didn't show it on the frontend
Build and Push Docker image / build-and-push (push) Successful in 1m51s
Details
Build and Push Docker image / build-and-push (push) Successful in 1m51s
Details
This commit is contained in:
parent
56a86ac3be
commit
1a666df795
|
@ -6,6 +6,7 @@ import {showErrorNotification, showSuccessNotification} from "@/components/util.
|
||||||
import {Alert, Button, Group, Modal, TextInput, Title} from "@mantine/core";
|
import {Alert, Button, Group, Modal, TextInput, Title} from "@mantine/core";
|
||||||
import {IconAt} from "@tabler/icons-react";
|
import {IconAt} from "@tabler/icons-react";
|
||||||
import {useLogin} from "@/components/users/modals/hooks.ts";
|
import {useLogin} from "@/components/users/modals/hooks.ts";
|
||||||
|
import {ClientResponseError} from "pocketbase";
|
||||||
|
|
||||||
export const EMAIL_TOKEN_KEY = "emailVerificationToken"
|
export const EMAIL_TOKEN_KEY = "emailVerificationToken"
|
||||||
|
|
||||||
|
@ -32,7 +33,8 @@ export default function EmailTokenVerification() {
|
||||||
|
|
||||||
const verifyTokenMutation = useMutation({
|
const verifyTokenMutation = useMutation({
|
||||||
mutationFn: async (token: string) => {
|
mutationFn: async (token: string) => {
|
||||||
await pb.collection("users").confirmVerification(token)
|
const res = await pb.collection("users").confirmVerification(token)
|
||||||
|
console.log({res})
|
||||||
},
|
},
|
||||||
onSuccess: () => {
|
onSuccess: () => {
|
||||||
showSuccessNotification("E-Mail erfolgreich verifiziert")
|
showSuccessNotification("E-Mail erfolgreich verifiziert")
|
||||||
|
@ -41,7 +43,8 @@ export default function EmailTokenVerification() {
|
||||||
loginHandler.open()
|
loginHandler.open()
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
onError: () => {
|
onError: (e) => {
|
||||||
|
if (e instanceof ClientResponseError && e.isAbort) return null
|
||||||
showErrorNotification("Fehler beim Verifizieren der E-Mail")
|
showErrorNotification("Fehler beim Verifizieren der E-Mail")
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
|
@ -105,12 +105,19 @@ const PocketData = () => {
|
||||||
const refreshUserQuery = useQuery({
|
const refreshUserQuery = useQuery({
|
||||||
queryKey: ["refreshUser"],
|
queryKey: ["refreshUser"],
|
||||||
queryFn: async () => {
|
queryFn: async () => {
|
||||||
|
// dont refresh if not logged in
|
||||||
|
if (!pb.authStore.isValid) return null
|
||||||
try {
|
try {
|
||||||
const record = await pb.collection(PB_USER_COLLECTION).getOne(pb.authStore.model?.id ?? "", {
|
const record = await pb.collection(PB_USER_COLLECTION).getOne(pb.authStore.model?.id ?? "", {
|
||||||
expand: "memberOf"
|
expand: "memberOf"
|
||||||
})
|
})
|
||||||
|
if (record.verified) {
|
||||||
pb.authStore.save(pb.authStore.token, record)
|
pb.authStore.save(pb.authStore.token, record)
|
||||||
return record
|
return record
|
||||||
|
} else {
|
||||||
|
pb.authStore.clear()
|
||||||
|
return null
|
||||||
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
if (e instanceof ClientResponseError && e.status === 401) {
|
if (e instanceof ClientResponseError && e.status === 401) {
|
||||||
pb.authStore.clear()
|
pb.authStore.clear()
|
||||||
|
|
Loading…
Reference in New Issue