Skip to content

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

No longer need to reload the page after signup/signin since we make current user reactive

Tianzhou Chend1d6692b65ae
diff --git a/frontend/src/components/ProfileDropdown.vue b/frontend/src/components/ProfileDropdown.vue
index 7125e89f59..265d9b8d20 100644
--- a/frontend/src/components/ProfileDropdown.vue
+++ b/frontend/src/components/ProfileDropdown.vue
@@ -84,12 +84,14 @@
<script lang="ts">
import { computed } from "vue";
import { useStore } from "vuex";
+import { useRouter } from "vue-router";
export default {
name: "ProfileDropdown",
props: {},
setup(props, ctx) {
const store = useStore();
+ const router = useRouter();
const currentUser = computed(() => store.getters["auth/currentUser"]());
@@ -97,8 +99,8 @@ export default {
store
.dispatch("auth/logout")
.then(() => {
- // Just do a reload. router.push won't refresh the app.vue page.
- // It's acceptable to use reload for logout.
+ // If using router.push, looks like hook reactive to currentUser would get called first.
+ // So we just do a reload here.
location.reload();
})
.catch((error: Error) => {
diff --git a/frontend/src/views/auth/Signin.vue b/frontend/src/views/auth/Signin.vue
index 911f172cf1..05280fde04 100644
--- a/frontend/src/views/auth/Signin.vue
+++ b/frontend/src/views/auth/Signin.vue
@@ -130,6 +130,7 @@
<script lang="ts">
import { reactive } from "vue";
import { useStore } from "vuex";
+import { useRouter } from "vue-router";
import { LoginInfo } from "../../types";
interface LocalState {
@@ -142,6 +143,7 @@ export default {
name: "Signin",
setup(props, ctx) {
const store = useStore();
+ const router = useRouter();
const state = reactive<LocalState>({
email: "",
@@ -157,8 +159,7 @@ export default {
store
.dispatch("auth/login", loginInfo)
.then(() => {
- // Do a full page reload to avoid stale UI state.
- location.replace("/");
+ router.push("/");
})
.catch((error: Error) => {
console.log(error);
diff --git a/frontend/src/views/auth/Signup.vue b/frontend/src/views/auth/Signup.vue
index ec63b56793..624a8f48d2 100644
--- a/frontend/src/views/auth/Signup.vue
+++ b/frontend/src/views/auth/Signup.vue
@@ -125,6 +125,7 @@
<script lang="ts">
import { reactive } from "vue";
import { useStore } from "vuex";
+import { useRouter } from "vue-router";
import { SignupInfo } from "../../types";
interface LocalState {
@@ -137,6 +138,7 @@ export default {
name: "Signup",
setup(props, ctx) {
const store = useStore();
+ const router = useRouter();
const state = reactive<LocalState>({
email: "",
@@ -152,8 +154,7 @@ export default {
store
.dispatch("auth/signup", signupInfo)
.then(() => {
- // Do a full page reload to avoid stale UI state.
- location.replace("/");
+ router.push("/");
})
.catch((error: Error) => {
console.log(error);