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 {IconAt} from "@tabler/icons-react";
|
||||
import {useLogin} from "@/components/users/modals/hooks.ts";
|
||||
import {ClientResponseError} from "pocketbase";
|
||||
|
||||
export const EMAIL_TOKEN_KEY = "emailVerificationToken"
|
||||
|
||||
|
@ -32,7 +33,8 @@ export default function EmailTokenVerification() {
|
|||
|
||||
const verifyTokenMutation = useMutation({
|
||||
mutationFn: async (token: string) => {
|
||||
await pb.collection("users").confirmVerification(token)
|
||||
const res = await pb.collection("users").confirmVerification(token)
|
||||
console.log({res})
|
||||
},
|
||||
onSuccess: () => {
|
||||
showSuccessNotification("E-Mail erfolgreich verifiziert")
|
||||
|
@ -41,7 +43,8 @@ export default function EmailTokenVerification() {
|
|||
loginHandler.open()
|
||||
}
|
||||
},
|
||||
onError: () => {
|
||||
onError: (e) => {
|
||||
if (e instanceof ClientResponseError && e.isAbort) return null
|
||||
showErrorNotification("Fehler beim Verifizieren der E-Mail")
|
||||
}
|
||||
})
|
||||
|
|
|
@ -105,12 +105,19 @@ const PocketData = () => {
|
|||
const refreshUserQuery = useQuery({
|
||||
queryKey: ["refreshUser"],
|
||||
queryFn: async () => {
|
||||
// dont refresh if not logged in
|
||||
if (!pb.authStore.isValid) return null
|
||||
try {
|
||||
const record = await pb.collection(PB_USER_COLLECTION).getOne(pb.authStore.model?.id ?? "", {
|
||||
expand: "memberOf"
|
||||
})
|
||||
pb.authStore.save(pb.authStore.token, record)
|
||||
return record
|
||||
if (record.verified) {
|
||||
pb.authStore.save(pb.authStore.token, record)
|
||||
return record
|
||||
} else {
|
||||
pb.authStore.clear()
|
||||
return null
|
||||
}
|
||||
} catch (e) {
|
||||
if (e instanceof ClientResponseError && e.status === 401) {
|
||||
pb.authStore.clear()
|
||||
|
|
Loading…
Reference in New Issue