better-auth-nuxt 0.0.9 → 0.0.10-beta.20
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/README.md +19 -270
- package/dist/module.d.mts +13 -40
- package/dist/module.json +8 -5
- package/dist/module.mjs +625 -358
- package/dist/runtime/adapters/convex.d.ts +111 -0
- package/dist/runtime/adapters/convex.js +213 -0
- package/dist/runtime/app/components/BetterAuthState.d.vue.ts +20 -0
- package/dist/runtime/app/components/BetterAuthState.vue +9 -0
- package/dist/runtime/app/components/BetterAuthState.vue.d.ts +20 -0
- package/dist/runtime/app/composables/useUserSession.d.ts +22 -0
- package/dist/runtime/app/composables/useUserSession.js +159 -0
- package/dist/runtime/app/middleware/auth.global.d.ts +13 -0
- package/dist/runtime/app/middleware/auth.global.js +37 -0
- package/dist/runtime/app/pages/__better-auth-devtools.d.vue.ts +3 -0
- package/dist/runtime/app/pages/__better-auth-devtools.vue +426 -0
- package/dist/runtime/app/pages/__better-auth-devtools.vue.d.ts +3 -0
- package/dist/runtime/app/plugins/session.client.d.ts +2 -0
- package/dist/runtime/app/plugins/session.client.js +15 -0
- package/dist/runtime/app/plugins/session.server.d.ts +2 -0
- package/dist/runtime/app/plugins/session.server.js +24 -0
- package/dist/runtime/config.d.ts +49 -0
- package/dist/runtime/config.js +11 -0
- package/dist/runtime/server/api/_better-auth/_schema.d.ts +16 -0
- package/dist/runtime/server/api/_better-auth/_schema.js +11 -0
- package/dist/runtime/server/api/_better-auth/accounts.get.d.ts +14 -0
- package/dist/runtime/server/api/_better-auth/accounts.get.js +28 -0
- package/dist/runtime/server/api/_better-auth/config.get.d.ts +35 -0
- package/dist/runtime/server/api/_better-auth/config.get.js +47 -0
- package/dist/runtime/server/api/_better-auth/sessions.delete.d.ts +4 -0
- package/dist/runtime/server/api/_better-auth/sessions.delete.js +22 -0
- package/dist/runtime/server/api/_better-auth/sessions.get.d.ts +14 -0
- package/dist/runtime/server/api/_better-auth/sessions.get.js +43 -0
- package/dist/runtime/server/api/_better-auth/users.get.d.ts +14 -0
- package/dist/runtime/server/api/_better-auth/users.get.js +34 -0
- package/dist/runtime/server/api/auth/[...all].d.ts +2 -0
- package/dist/runtime/server/api/auth/[...all].js +6 -0
- package/dist/runtime/server/middleware/route-access.d.ts +2 -0
- package/dist/runtime/server/middleware/route-access.js +29 -0
- package/dist/runtime/server/tsconfig.json +1 -1
- package/dist/runtime/server/utils/auth.d.ts +7 -0
- package/dist/runtime/server/utils/auth.js +81 -0
- package/dist/runtime/server/utils/session.d.ts +9 -0
- package/dist/runtime/server/utils/session.js +23 -0
- package/dist/runtime/types/augment.d.ts +42 -0
- package/dist/runtime/types/augment.js +0 -0
- package/dist/runtime/types.d.ts +23 -0
- package/dist/runtime/types.js +0 -0
- package/dist/runtime/utils/match-user.d.ts +2 -0
- package/dist/runtime/utils/match-user.js +13 -0
- package/dist/types.d.mts +8 -6
- package/package.json +82 -29
- package/LICENSE +0 -21
- package/dist/runtime/middleware/auth.d.ts +0 -2
- package/dist/runtime/middleware/auth.js +0 -31
- package/dist/runtime/plugin.d.ts +0 -2
- package/dist/runtime/plugin.js +0 -3
- package/dist/runtime/server/handler.d.ts +0 -2
- package/dist/runtime/server/handler.js +0 -5
- package/dist/runtime/server.d.ts +0 -6
- package/dist/runtime/server.js +0 -5
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { defu } from "defu";
|
|
2
|
-
import { defineNuxtRouteMiddleware, navigateTo } from "#app";
|
|
3
|
-
import { useUserSession } from "#imports";
|
|
4
|
-
export default defineNuxtRouteMiddleware(async (to) => {
|
|
5
|
-
if (to.meta?.auth === false) {
|
|
6
|
-
return;
|
|
7
|
-
}
|
|
8
|
-
const { loggedIn, options, fetchSession, session } = useUserSession();
|
|
9
|
-
const { only, redirectUserTo, redirectGuestTo, redirectUnauthorizedTo } = defu(to.meta.auth, options);
|
|
10
|
-
await fetchSession();
|
|
11
|
-
if (only === "guest" && loggedIn.value) {
|
|
12
|
-
if (to.path === redirectUserTo) {
|
|
13
|
-
return;
|
|
14
|
-
}
|
|
15
|
-
return navigateTo(redirectUserTo);
|
|
16
|
-
}
|
|
17
|
-
if (only && only !== "guest" && !loggedIn.value) {
|
|
18
|
-
if (to.path === redirectGuestTo)
|
|
19
|
-
return;
|
|
20
|
-
return navigateTo(redirectGuestTo);
|
|
21
|
-
}
|
|
22
|
-
if (only && only !== "guest" && loggedIn.value && session.value) {
|
|
23
|
-
const userRole = session.value.role || "user";
|
|
24
|
-
const requiredRoles = Array.isArray(only) ? only : [only];
|
|
25
|
-
if (!requiredRoles.includes(userRole) && !requiredRoles.includes("user")) {
|
|
26
|
-
if (to.path === redirectUnauthorizedTo)
|
|
27
|
-
return;
|
|
28
|
-
return navigateTo(redirectUnauthorizedTo ?? "/401");
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
});
|
package/dist/runtime/plugin.d.ts
DELETED
package/dist/runtime/plugin.js
DELETED
package/dist/runtime/server.d.ts
DELETED