diff options
author | vnugent <public@vaughnnugent.com> | 2024-01-01 12:32:14 -0500 |
---|---|---|
committer | vnugent <public@vaughnnugent.com> | 2024-01-01 12:32:14 -0500 |
commit | 0ca26fc63cc5311298575209b124516139f58206 (patch) | |
tree | b7062317330da4b79a31d47cfd5a39b939fbc723 /lib/vnlib.browser/src/helpers/pageGuard.ts | |
parent | 4890ffb8f4aafed897cabc368fa105a70615a2de (diff) |
package updates, pageguard & dead exports
Diffstat (limited to 'lib/vnlib.browser/src/helpers/pageGuard.ts')
-rw-r--r-- | lib/vnlib.browser/src/helpers/pageGuard.ts | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/lib/vnlib.browser/src/helpers/pageGuard.ts b/lib/vnlib.browser/src/helpers/pageGuard.ts index c3a767b..e6a92c6 100644 --- a/lib/vnlib.browser/src/helpers/pageGuard.ts +++ b/lib/vnlib.browser/src/helpers/pageGuard.ts @@ -1,4 +1,4 @@ -// Copyright (c) 2023 Vaughn Nugent +// Copyright (c) 2024 Vaughn Nugent // // Permission is hereby granted, free of charge, to any person obtaining a copy of // this software and associated documentation files (the "Software"), to deal in @@ -20,8 +20,12 @@ import { watch } from 'vue' import { useSession } from "../session"; import { useLastPage } from './lastPage'; -import type { ILastPageStorage } from "./lastPage"; +import type { ILastPageStorage, RouterLike } from "./lastPage"; +export interface PageGuardOptions { + readonly stack: ILastPageStorage; + readonly router: RouterLike; +} /** * When called, configures the component to @@ -30,12 +34,12 @@ import type { ILastPageStorage } from "./lastPage"; * @remarks Once called, if the user is logged-in changes will be * watch to redirect if the user becomes logged out. */ -export const usePageGuard = (loginRoute = { name: 'Login' }, lpStorage?: ILastPageStorage): void => { +export const usePageGuard = (loginRoute = { name: 'Login' }, options?: Partial<PageGuardOptions>): void => { //Get the session state const session = useSession(); //Get last page controller, fall back to default session storage stack - const { pushAndNavigate } = useLastPage(lpStorage) + const { pushAndNavigate } = useLastPage(options?.stack, options?.router) // Initial check for logged in to guard the page if (!session.loggedIn.value) { |