@onmax/nuxt-better-auth 0.0.2-alpha.1 → 0.0.2-alpha.2

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/module.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "compatibility": {
5
5
  "nuxt": ">=3.0.0"
6
6
  },
7
- "version": "0.0.2-alpha.1",
7
+ "version": "0.0.2-alpha.2",
8
8
  "builder": {
9
9
  "@nuxt/module-builder": "1.0.2",
10
10
  "unbuild": "3.6.1"
@@ -1,5 +1,5 @@
1
1
  import { createAppAuthClient } from "#auth/client";
2
- import { computed, useRequestHeaders, useRequestURL, useRuntimeConfig, useState, watch } from "#imports";
2
+ import { computed, nextTick, useRequestHeaders, useRequestURL, useRuntimeConfig, useState, watch } from "#imports";
3
3
  import { consola } from "consola";
4
4
  let _client = null;
5
5
  function getClient(baseURL) {
@@ -62,6 +62,9 @@ export function useUserSession() {
62
62
  function wrapOnSuccess(cb) {
63
63
  return async (ctx) => {
64
64
  await fetchSession({ force: true });
65
+ if (!loggedIn.value)
66
+ await waitForSession();
67
+ await nextTick();
65
68
  await cb(ctx);
66
69
  };
67
70
  }
@@ -10,8 +10,8 @@ export default defineNuxtRouteMiddleware(async (to) => {
10
10
  if (auth === void 0 || auth === false)
11
11
  return;
12
12
  const config = useRuntimeConfig().public.auth;
13
- const { fetchSession, user, loggedIn, ready } = useUserSession();
14
- if (!loggedIn.value && !ready.value) {
13
+ const { fetchSession, user, loggedIn } = useUserSession();
14
+ if (!loggedIn.value) {
15
15
  const headers = import.meta.server ? useRequestHeaders(["cookie"]) : void 0;
16
16
  await fetchSession({ headers });
17
17
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@onmax/nuxt-better-auth",
3
3
  "type": "module",
4
- "version": "0.0.2-alpha.1",
4
+ "version": "0.0.2-alpha.2",
5
5
  "packageManager": "pnpm@10.15.1",
6
6
  "description": "Nuxt module for Better Auth integration with NuxtHub, route protection, session management, and role-based access",
7
7
  "author": "onmax",