svelte-guard-history-router
Advanced tools
Comparing version 2.22.0 to 2.23.0
{ | ||
"name": "svelte-guard-history-router", | ||
"version": "2.22.0", | ||
"version": "2.23.0", | ||
"publishConfig": { | ||
@@ -5,0 +5,0 @@ "access": "public" |
@@ -31,13 +31,7 @@ [![Svelte v3](https://img.shields.io/badge/svelte-v3-orange.svg)](https://svelte.dev) | ||
```js | ||
import { Guard } from 'svelte-guard-history-router'; | ||
import { redirectGuard } from 'svelte-guard-history-router'; | ||
let session = undefined; | ||
class SessionGuard extends Guard { | ||
async enter(transition) { | ||
if(!session) { | ||
return transition.redirect('/login'); | ||
} | ||
} | ||
} | ||
export const enshureSession = redirectGuard("/login", () => !session); | ||
``` | ||
@@ -54,3 +48,3 @@ | ||
import { sessionGuard } from "./main.mjs"; | ||
import { enshureSession } from "./main.mjs"; | ||
</script> | ||
@@ -67,3 +61,3 @@ | ||
<li> | ||
<Route path="/article" guards={sessionGuard} component={Articles}> | ||
<Route path="/article" guards={enshureSession} component={Articles}> | ||
Articles | ||
@@ -74,3 +68,3 @@ <Route path="/:artice" component={Article}/> | ||
<li> | ||
<Route path="/category" guards={sessionGuard} component={Categories}> | ||
<Route path="/category" guards={enshureSession} component={Categories}> | ||
Categories | ||
@@ -77,0 +71,0 @@ <Route path="/:category" component={Category}/> |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
39993
697
523