feat: login from token in widget

This commit is contained in:
Tristan Yang
2023-11-21 09:26:47 +08:00
parent 128fac9427
commit abf0ced2f9
9 changed files with 361 additions and 364 deletions
+5 -5
View File
@@ -15,7 +15,7 @@ import baseQuery from "./base.query";
const getDeviceId = () => {
let d = localStorage.getItem(KEY_DEVICE_ID);
let dt = localStorage.getItem(KEY_DEVICE_TOKEN) || "";
const dt = localStorage.getItem(KEY_DEVICE_TOKEN) || "";
if (!d) {
d = `web:${nanoid()}`;
localStorage.setItem(KEY_DEVICE_ID, d);
@@ -53,7 +53,7 @@ export const authApi = createApi({
if (data) {
dispatch(setAuthData(data));
}
// 从localstorage 去掉 magic token
// 从 localstorage 去掉 magic token
localStorage.removeItem(KEY_LOCAL_MAGIC_TOKEN);
} catch {
console.log("login error");
@@ -67,7 +67,7 @@ export const authApi = createApi({
const { data } = await queryFulfilled;
if (data) {
dispatch(setAuthData(data));
// 从localstorage 去掉 magic token
// 从 localstorage 去掉 magic token
localStorage.removeItem(KEY_LOCAL_MAGIC_TOKEN);
}
} catch {
@@ -86,7 +86,7 @@ export const authApi = createApi({
}
})
}),
// 更新token
// 更新 token
renew: builder.mutation<RenewTokenResponse, RenewTokenDTO>({
query: (data) => ({
url: "/token/renew",
@@ -116,7 +116,7 @@ export const authApi = createApi({
}
})
}),
// 获取openid
// 获取 openid
getOpenid: builder.mutation<{ url: string }, { issuer: string; redirect_uri: string }>({
query: (data) => ({
url: "/token/openid/authorize",