@txstate-mws/sveltekit-utils 1.1.3 → 1.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/unifiedauth.d.ts +1 -0
- package/dist/unifiedauth.js +9 -0
- package/package.json +1 -1
package/dist/unifiedauth.d.ts
CHANGED
|
@@ -19,6 +19,7 @@ export declare const unifiedAuth: {
|
|
|
19
19
|
*/
|
|
20
20
|
handle(api: APIBase, input: LoadEvent, opts?: HandleOpts): Promise<void>;
|
|
21
21
|
loginRedirect(api: APIBase, currentUrl: string): URL;
|
|
22
|
+
logoutHref(api: APIBase): string;
|
|
22
23
|
requireAuth(api: APIBase, input: LoadEvent): void;
|
|
23
24
|
};
|
|
24
25
|
export {};
|
package/dist/unifiedauth.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { redirect } from '@sveltejs/kit';
|
|
2
|
+
import { isBlank } from 'txstate-utils';
|
|
2
3
|
export const unifiedAuth = {
|
|
3
4
|
/**
|
|
4
5
|
* Your root +layout.ts' load function should call this method to ensure that it
|
|
@@ -28,6 +29,14 @@ export const unifiedAuth = {
|
|
|
28
29
|
loginRedirect.searchParams.set('requestedUrl', currentUrl);
|
|
29
30
|
return loginRedirect;
|
|
30
31
|
},
|
|
32
|
+
logoutHref(api) {
|
|
33
|
+
if (isBlank(api.token))
|
|
34
|
+
return '#';
|
|
35
|
+
const authRedirect = new URL(api.authRedirect);
|
|
36
|
+
authRedirect.pathname = '/logout';
|
|
37
|
+
authRedirect.searchParams.set('unifiedJwt', api.token);
|
|
38
|
+
return authRedirect.toString();
|
|
39
|
+
},
|
|
31
40
|
requireAuth(api, input) {
|
|
32
41
|
if (!api.token) {
|
|
33
42
|
throw redirect(302, this.loginRedirect(api, input.url.toString()));
|