mirror of
https://github.com/certd/certd.git
synced 2026-06-10 10:37:34 +08:00
chore(auth): 清理已使用的邀请码缓存
This commit is contained in:
@@ -15,6 +15,7 @@ import { resetAllStores, useAccessStore } from "/@/vben/stores";
|
||||
|
||||
import { useUserStore as vbenUserStore } from "/@/vben/stores/modules/user";
|
||||
import { request } from "/@/api/service";
|
||||
import { inviteUtils } from "/@/utils/util.invite";
|
||||
|
||||
interface UserState {
|
||||
userInfo: Nullable<UserInfoRes>;
|
||||
@@ -66,6 +67,9 @@ export const useUserStore = defineStore({
|
||||
},
|
||||
async register(user: RegisterReq) {
|
||||
await UserApi.register(user);
|
||||
if (user.inviteCode) {
|
||||
inviteUtils.clear();
|
||||
}
|
||||
notification.success({
|
||||
message: "注册成功,请登录",
|
||||
});
|
||||
@@ -85,6 +89,9 @@ export const useUserStore = defineStore({
|
||||
let loginRes: any = null;
|
||||
if (loginType === "sms") {
|
||||
loginRes = await UserApi.loginBySms(params as SmsLoginReq);
|
||||
if ((params as SmsLoginReq).inviteCode) {
|
||||
inviteUtils.clear();
|
||||
}
|
||||
} else {
|
||||
loginRes = await UserApi.login(params as LoginReq);
|
||||
}
|
||||
|
||||
@@ -41,6 +41,10 @@ export const inviteUtils = {
|
||||
}
|
||||
},
|
||||
|
||||
clear() {
|
||||
localStorage.removeItem(INVITE_STORAGE_KEY);
|
||||
},
|
||||
|
||||
captureFromLocation() {
|
||||
const hashQuery = window.location.hash?.split("?")[1] || "";
|
||||
const search = window.location.search?.replace(/^\?/, "") || "";
|
||||
|
||||
@@ -100,7 +100,11 @@ async function goBindUser() {
|
||||
|
||||
async function autoRegister() {
|
||||
//自动注册账号
|
||||
const res = await api.AutoRegister(oauthType, bindCode.value, inviteUtils.get());
|
||||
const inviteCode = inviteUtils.get();
|
||||
const res = await api.AutoRegister(oauthType, bindCode.value, inviteCode);
|
||||
if (inviteCode) {
|
||||
inviteUtils.clear();
|
||||
}
|
||||
//登录成功
|
||||
userStore.onLoginSuccess(res);
|
||||
//跳转到首页
|
||||
|
||||
Reference in New Issue
Block a user