From 10d76d0a035cf15d77ed0e3060086e8aa29ad7ac Mon Sep 17 00:00:00 2001 From: Daniel Roe Date: Wed, 17 Jan 2024 11:32:16 +0000 Subject: [PATCH 1/7] fix: move vue server plugin out of `server/` directory (#639) --- src/module.ts | 2 +- src/runtime/{server => }/plugins/refresh-token.server.ts | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) rename src/runtime/{server => }/plugins/refresh-token.server.ts (95%) diff --git a/src/module.ts b/src/module.ts index 4809978d..2d41bfdc 100644 --- a/src/module.ts +++ b/src/module.ts @@ -227,7 +227,7 @@ export default defineNuxtModule({ // 7.2 Add a server-plugin to refresh the token on production-startup if (selectedProvider === 'refresh') { - addPlugin(resolve('./runtime/server/plugins/refresh-token.server')) + addPlugin(resolve('./runtime/plugins/refresh-token.server')) } logger.success('`nuxt-auth` setup done') diff --git a/src/runtime/server/plugins/refresh-token.server.ts b/src/runtime/plugins/refresh-token.server.ts similarity index 95% rename from src/runtime/server/plugins/refresh-token.server.ts rename to src/runtime/plugins/refresh-token.server.ts index c7d90ec1..51490231 100644 --- a/src/runtime/server/plugins/refresh-token.server.ts +++ b/src/runtime/plugins/refresh-token.server.ts @@ -1,5 +1,5 @@ -import { _fetch } from '../../utils/fetch' -import { jsonPointerGet, useTypedBackendConfig } from '../../helpers' +import { _fetch } from '../utils/fetch' +import { jsonPointerGet, useTypedBackendConfig } from '../helpers' import { defineNuxtPlugin, useAuthState, useRuntimeConfig } from '#imports' export default defineNuxtPlugin({ name: 'refresh-token-plugin', From 0eea47a51e9b46650e921d8e5d5b10384fb9282c Mon Sep 17 00:00:00 2001 From: Zoey Date: Sat, 20 Jan 2024 02:50:37 +0100 Subject: [PATCH 2/7] release: 0.6.5 (#642) --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index dc7b0fb2..07227358 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@sidebase/nuxt-auth", - "version": "0.6.4", + "version": "0.6.5", "license": "MIT", "type": "module", "exports": { From cf32ea7a8fca84875c0b4ad9069c32bf6a0db69f Mon Sep 17 00:00:00 2001 From: Zoey Date: Mon, 22 Jan 2024 10:29:42 +0100 Subject: [PATCH 3/7] feat: Add server check in middleware (#644) --- src/runtime/middleware/auth.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/runtime/middleware/auth.ts b/src/runtime/middleware/auth.ts index d23d48b8..c2f3badb 100644 --- a/src/runtime/middleware/auth.ts +++ b/src/runtime/middleware/auth.ts @@ -85,6 +85,10 @@ export default defineNuxtRouteMiddleware((to) => { } if (authConfig.provider.type === 'authjs') { + // If the middleware runs on a pre-render of the route, do not call signIn, as this is a client method + if (process.server) { + return + } const signInOptions: Parameters[1] = { error: 'SessionRequired', callbackUrl: determineCallbackUrl(authConfig, () => to.path) } // @ts-ignore This is valid for a backend-type of `authjs`, where sign-in accepts a provider as a first argument return signIn(undefined, signInOptions) as ReturnType From 59a17f55d775b0931ee7de23f710f3544337e756 Mon Sep 17 00:00:00 2001 From: Abdallah Alhaddad <54389201+AbdallahAlhaddad@users.noreply.github.com> Date: Mon, 22 Jan 2024 01:34:59 -0800 Subject: [PATCH 4/7] fix: include hash & query parameters in callbackUrl (#643) --- src/runtime/middleware/auth.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/runtime/middleware/auth.ts b/src/runtime/middleware/auth.ts index c2f3badb..a1547f71 100644 --- a/src/runtime/middleware/auth.ts +++ b/src/runtime/middleware/auth.ts @@ -89,7 +89,7 @@ export default defineNuxtRouteMiddleware((to) => { if (process.server) { return } - const signInOptions: Parameters[1] = { error: 'SessionRequired', callbackUrl: determineCallbackUrl(authConfig, () => to.path) } + const signInOptions: Parameters[1] = { error: 'SessionRequired', callbackUrl: determineCallbackUrl(authConfig, () => to.fullPath) } // @ts-ignore This is valid for a backend-type of `authjs`, where sign-in accepts a provider as a first argument return signIn(undefined, signInOptions) as ReturnType } else if (typeof metaAuth === 'object' && metaAuth.navigateUnauthenticatedTo) { From 5e87a489cc8288af26ccfb2c8933b704c20352d5 Mon Sep 17 00:00:00 2001 From: Zoey Date: Mon, 22 Jan 2024 10:37:00 +0100 Subject: [PATCH 5/7] release: 0.6.6 (#645) --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 07227358..893e9ba5 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@sidebase/nuxt-auth", - "version": "0.6.5", + "version": "0.6.6", "license": "MIT", "type": "module", "exports": { From 67d33bb341a6d86c2f5218ae4aacaa4792551469 Mon Sep 17 00:00:00 2001 From: Zoey Kaiser Date: Mon, 22 Jan 2024 10:59:41 +0100 Subject: [PATCH 6/7] Revert: https://github.com/sidebase/nuxt-auth/pull/644 --- src/runtime/middleware/auth.ts | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/runtime/middleware/auth.ts b/src/runtime/middleware/auth.ts index a1547f71..8e6109df 100644 --- a/src/runtime/middleware/auth.ts +++ b/src/runtime/middleware/auth.ts @@ -85,10 +85,6 @@ export default defineNuxtRouteMiddleware((to) => { } if (authConfig.provider.type === 'authjs') { - // If the middleware runs on a pre-render of the route, do not call signIn, as this is a client method - if (process.server) { - return - } const signInOptions: Parameters[1] = { error: 'SessionRequired', callbackUrl: determineCallbackUrl(authConfig, () => to.fullPath) } // @ts-ignore This is valid for a backend-type of `authjs`, where sign-in accepts a provider as a first argument return signIn(undefined, signInOptions) as ReturnType From 0bc80f7ecd52e5fac856104249ea98f45fddf974 Mon Sep 17 00:00:00 2001 From: Zoey Kaiser Date: Mon, 22 Jan 2024 11:00:07 +0100 Subject: [PATCH 7/7] release: 0.6.7 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 893e9ba5..8792323f 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@sidebase/nuxt-auth", - "version": "0.6.6", + "version": "0.6.7", "license": "MIT", "type": "module", "exports": {