feat: magic link login/reg

This commit is contained in:
zerosoul
2022-05-09 21:17:49 +08:00
parent f3b82295d6
commit 1b1cfb956e
16 changed files with 760 additions and 350 deletions
+16
View File
@@ -90,6 +90,13 @@ export const authApi = createApi({
body: { old_password, new_password },
}),
}),
sendMagicLink: builder.mutation({
query: (email) => ({
url: "token/send_magic_link",
method: "POST",
body: { email },
}),
}),
getMetamaskNonce: builder.query({
query: (address) => ({
url: `/token/metamask/nonce?public_address=${address}`,
@@ -102,11 +109,20 @@ export const authApi = createApi({
}),
logout: builder.query({
query: () => ({ url: `token/logout` }),
async onQueryStarted(params, { dispatch, queryFulfilled }) {
try {
await queryFulfilled;
dispatch(resetAuthData());
} catch {
console.log("logout error");
}
},
}),
}),
});
export const {
useSendMagicLinkMutation,
useGetCredentialsQuery,
useUpdateDeviceTokenMutation,
useGetOpenidMutation,
+1
View File
@@ -6,6 +6,7 @@ import BASE_URL, { tokenHeader } from "../config";
const whiteList = [
"login",
"register",
"sendMagicLink",
"checkInviteTokenValid",
"getLoginConfig",
"getServer",