feat(client): magic link sign-in
Signed-off-by: Noa Virellia <noa@requiem.garden>
This commit is contained in:
15
client/src/hooks/data/useGetMagicLink.ts
Normal file
15
client/src/hooks/data/useGetMagicLink.ts
Normal file
@@ -0,0 +1,15 @@
|
||||
import { useMutation } from '@tanstack/react-query';
|
||||
import { axiosClient } from '@/lib/axios';
|
||||
|
||||
interface GetMagicLinkPayload {
|
||||
email: string;
|
||||
turnstile_token: string;
|
||||
}
|
||||
|
||||
export function useGetMagicLink() {
|
||||
return useMutation({
|
||||
mutationFn: async (payload: GetMagicLinkPayload) => {
|
||||
return axiosClient.post<object>('/auth/magic', payload);
|
||||
},
|
||||
});
|
||||
}
|
||||
11
client/src/hooks/data/useValidateMagicLink.ts
Normal file
11
client/src/hooks/data/useValidateMagicLink.ts
Normal file
@@ -0,0 +1,11 @@
|
||||
import { useSuspenseQuery } from '@tanstack/react-query';
|
||||
import { axiosClient } from '@/lib/axios';
|
||||
|
||||
export function useValidateMagicLink(ticket: string) {
|
||||
return useSuspenseQuery({
|
||||
queryKey: ['validateMagicLink', ticket],
|
||||
queryFn: async () => {
|
||||
return axiosClient.get<{ jwt_token: string; email: string }>('/auth/magic/verify', { params: { token: ticket } });
|
||||
},
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user