Skip to content

Commit

Permalink
refactor(login): renamed to "connect"
Browse files Browse the repository at this point in the history
I think login is the wrong name for what it does. It is a connect
page / connection manager

Signed-off-by: Lukas Mertens <git@lukas-mertens.de>

commit-id:65f3ae04
  • Loading branch information
lukas-mertens committed Mar 19, 2024
1 parent e85f945 commit 1588a5f
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
File renamed without changes.
2 changes: 1 addition & 1 deletion src/pages/MainPanel.vue
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ export default defineComponent({
if (notification) {
notyf.dismiss(notification);
}
await router.push({path: "/login", query: {auto_connect: "false"}});
await router.push({path: "/connect", query: {auto_connect: "false"}});
},
},
created() {
Expand Down
16 changes: 8 additions & 8 deletions src/router/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,17 @@
import {createRouter, createWebHashHistory, RouteRecordRaw} from "vue-router";

import MainPanel from "../pages/MainPanel.vue";
import LoginPage from "../pages/LoginPage.vue";
import ConnectPage from "../pages/ConnectPage.vue";
import ConfigPage from "../pages/ConfigPage.vue";
import EVBackendClient from "@/modules/evbc/client";
import {inject} from "vue";


const routes: RouteRecordRaw[] = [
{
path: "/login",
name: "login",
component: LoginPage,
path: "/connect",
name: "connect",
component: ConnectPage,
},
{
path: "/",
Expand All @@ -37,17 +37,17 @@ export const router = createRouter({

router.beforeEach((to, from, next) => {
const evbc = inject<EVBackendClient>("evbc");
const userIsLoggedIn = evbc?.initialized;
const userIsConnected = evbc?.initialized;

// Redirect to ConfigPage if the user is logged in and navigating to the root path
if (to.path === "/" && userIsLoggedIn) {
if (to.path === "/" && userIsConnected) {
next("/config");
} else if (to.matched.some(record => record.meta.requiresConnection)) {
// Require connection for specific routes
if (userIsLoggedIn) {
if (userIsConnected) {
next();
} else {
next("/login"); // Redirect to login if not logged in and trying to access a protected route
next("/connect"); // Redirect to connect if not connected
}
} else {
// Proceed with the navigation for all other cases
Expand Down

0 comments on commit 1588a5f

Please sign in to comment.