Skip to content

Database governance built for humans and agents — controlling changes and access across every major database.

Fix when the user just signed up/activated, the info is not fetched.

天舟75fdcac778f6
diff --git a/frontend/src/store/modules/auth.ts b/frontend/src/store/modules/auth.ts
index 9e8ad0e565..170a4228c6 100644
--- a/frontend/src/store/modules/auth.ts
+++ b/frontend/src/store/modules/auth.ts
@@ -47,34 +47,45 @@ const actions = {
return loggedInUser;
},
- async signup({ commit, rootGetters }: any, signupInfo: SignupInfo) {
- const newUser = convert(
- (
- await axios.post("/api/auth/signup", {
- data: { type: "signupInfo", attributes: signupInfo },
- })
- ).data.data,
- rootGetters
- );
+ async signup({ commit, dispatch, rootGetters }: any, signupInfo: SignupInfo) {
+ const newUser = (
+ await axios.post("/api/auth/signup", {
+ data: { type: "signupInfo", attributes: signupInfo },
+ })
+ ).data.data;
+
+ // Refresh the corresponding principal
+ await dispatch("principal/fetchPrincipalById", newUser.id, { root: true });
+
+ // The conversion relies on the above step.
+ const convertedUser = convert(newUser, rootGetters);
+
+ localStorage.setItem("bb.auth.user", JSON.stringify(convertedUser));
+ commit("setCurrentUser", convertedUser);
- localStorage.setItem("bb.auth.user", JSON.stringify(newUser));
- commit("setCurrentUser", newUser);
- return newUser;
+ return convertedUser;
},
- async activate({ commit, rootGetters }: any, activateInfo: ActivateInfo) {
- const activatedUser = convert(
- (
- await axios.post("/api/auth/activate", {
- data: { type: "activateInfo", attributes: activateInfo },
- })
- ).data.data,
- rootGetters
- );
+ async activate(
+ { commit, dispatch, rootGetters }: any,
+ activateInfo: ActivateInfo
+ ) {
+ const activatedUser = (
+ await axios.post("/api/auth/activate", {
+ data: { type: "activateInfo", attributes: activateInfo },
+ })
+ ).data.data;
+
+ // Refresh the corresponding principal
+ dispatch("principal/fetchPrincipalById", activatedUser.id, { root: true });
+
+ // The conversion relies on the above step to get the lastest data
+ const convertedUser = convert(activatedUser, rootGetters);
+
+ localStorage.setItem("bb.auth.user", JSON.stringify(convertedUser));
+ commit("setCurrentUser", convertedUser);
- localStorage.setItem("bb.auth.user", JSON.stringify(activatedUser));
- commit("setCurrentUser", activatedUser);
- return activatedUser;
+ return convertedUser;
},
async restoreUser({ commit }: any) {
diff --git a/frontend/src/store/modules/principal.ts b/frontend/src/store/modules/principal.ts
index f902fb668d..0071c0fb52 100644
--- a/frontend/src/store/modules/principal.ts
+++ b/frontend/src/store/modules/principal.ts
@@ -72,7 +72,7 @@ const actions = {
rootGetters
);
- commit("replacePrincipalInList", principal);
+ commit("upsertPrincipalInList", principal);
return principal;
},
@@ -120,7 +120,7 @@ const actions = {
rootGetters
);
- commit("replacePrincipalInList", updatedPrincipal);
+ commit("upsertPrincipalInList", updatedPrincipal);
return updatedPrincipal;
},
@@ -135,11 +135,13 @@ const mutations = {
state.principalList.push(newPrincipal);
},
- replacePrincipalInList(state: PrincipalState, updatedPrincipal: Principal) {
+ upsertPrincipalInList(state: PrincipalState, updatedPrincipal: Principal) {
const i = state.principalList.findIndex(
(item: Principal) => item.id == updatedPrincipal.id
);
- if (i != -1) {
+ if (i == -1) {
+ state.principalList.push(updatedPrincipal);
+ } else {
state.principalList[i] = updatedPrincipal;
}
},