Redirect from Login page to Homepage if already logged-in

Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
Thomas Citharel 2021-08-09 08:59:46 +02:00
parent 16f90254a0
commit bfc9dd7ea3
No known key found for this signature in database
GPG Key ID: A061B9DDE0CA0773
1 changed files with 8 additions and 1 deletions

View File

@ -118,7 +118,7 @@
</template>
<script lang="ts">
import { Component, Prop, Vue } from "vue-property-decorator";
import { Component, Prop, Vue, Watch } from "vue-property-decorator";
import { Route } from "vue-router";
import { ICurrentUser } from "@/types/current-user.model";
import { LoginError, LoginErrorCode } from "@/types/enums";
@ -269,6 +269,13 @@ export default class Login extends Vue {
}
}
}
@Watch("currentUser")
redirectToHomepageIfAlreadyLoggedIn(): Promise<Route> | void {
if (this.currentUser.isLoggedIn) {
return this.$router.push("/");
}
}
}
</script>