@riligar/auth-elysia 1.6.1 → 1.6.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/index.esm.js +6 -10
- package/dist/index.js +6 -10
- package/package.json +1 -1
- package/src/index.js +5 -9
package/dist/index.esm.js
CHANGED
|
@@ -237,11 +237,7 @@ function authPlugin(userConfig = {}) {
|
|
|
237
237
|
|
|
238
238
|
return app => {
|
|
239
239
|
app.derive(async ({ request, cookie }) => {
|
|
240
|
-
|
|
241
|
-
// Verificar se a rota deve ser excluída da autenticação
|
|
242
|
-
if (config.excludePaths.some(excluded => path.startsWith(excluded))) {
|
|
243
|
-
return { user: null, authMeta: null }
|
|
244
|
-
}
|
|
240
|
+
new URL(request.url).pathname;
|
|
245
241
|
|
|
246
242
|
// Buscar token no cookie ou header Authorization
|
|
247
243
|
let token = cookie[config.cookieName]?.value;
|
|
@@ -278,12 +274,12 @@ function authPlugin(userConfig = {}) {
|
|
|
278
274
|
}
|
|
279
275
|
}).onBeforeHandle(({ user, set, request }) => {
|
|
280
276
|
const path = new URL(request.url).pathname;
|
|
281
|
-
// Verificar se a rota deve ser excluída da autenticação (guard redundante por segurança)
|
|
282
|
-
if (config.excludePaths.some(excluded => path.startsWith(excluded))) {
|
|
283
|
-
return
|
|
284
|
-
}
|
|
285
277
|
|
|
286
|
-
//
|
|
278
|
+
// Verificar se a rota deve ser excluída da autenticação
|
|
279
|
+
const isExcluded = config.excludePaths.some(excluded => path.startsWith(excluded));
|
|
280
|
+
if (isExcluded) return
|
|
281
|
+
|
|
282
|
+
// Bloquear se não houver usuário
|
|
287
283
|
if (!user) {
|
|
288
284
|
return config.onUnauthorized(set)
|
|
289
285
|
}
|
package/dist/index.js
CHANGED
|
@@ -241,11 +241,7 @@ function authPlugin(userConfig = {}) {
|
|
|
241
241
|
|
|
242
242
|
return app => {
|
|
243
243
|
app.derive(async ({ request, cookie }) => {
|
|
244
|
-
|
|
245
|
-
// Verificar se a rota deve ser excluída da autenticação
|
|
246
|
-
if (config.excludePaths.some(excluded => path.startsWith(excluded))) {
|
|
247
|
-
return { user: null, authMeta: null }
|
|
248
|
-
}
|
|
244
|
+
new URL(request.url).pathname;
|
|
249
245
|
|
|
250
246
|
// Buscar token no cookie ou header Authorization
|
|
251
247
|
let token = cookie[config.cookieName]?.value;
|
|
@@ -282,12 +278,12 @@ function authPlugin(userConfig = {}) {
|
|
|
282
278
|
}
|
|
283
279
|
}).onBeforeHandle(({ user, set, request }) => {
|
|
284
280
|
const path = new URL(request.url).pathname;
|
|
285
|
-
// Verificar se a rota deve ser excluída da autenticação (guard redundante por segurança)
|
|
286
|
-
if (config.excludePaths.some(excluded => path.startsWith(excluded))) {
|
|
287
|
-
return
|
|
288
|
-
}
|
|
289
281
|
|
|
290
|
-
//
|
|
282
|
+
// Verificar se a rota deve ser excluída da autenticação
|
|
283
|
+
const isExcluded = config.excludePaths.some(excluded => path.startsWith(excluded));
|
|
284
|
+
if (isExcluded) return
|
|
285
|
+
|
|
286
|
+
// Bloquear se não houver usuário
|
|
291
287
|
if (!user) {
|
|
292
288
|
return config.onUnauthorized(set)
|
|
293
289
|
}
|
package/package.json
CHANGED
package/src/index.js
CHANGED
|
@@ -237,10 +237,6 @@ export function authPlugin(userConfig = {}) {
|
|
|
237
237
|
return app => {
|
|
238
238
|
app.derive(async ({ request, cookie }) => {
|
|
239
239
|
const path = new URL(request.url).pathname
|
|
240
|
-
// Verificar se a rota deve ser excluída da autenticação
|
|
241
|
-
if (config.excludePaths.some(excluded => path.startsWith(excluded))) {
|
|
242
|
-
return { user: null, authMeta: null }
|
|
243
|
-
}
|
|
244
240
|
|
|
245
241
|
// Buscar token no cookie ou header Authorization
|
|
246
242
|
let token = cookie[config.cookieName]?.value
|
|
@@ -277,12 +273,12 @@ export function authPlugin(userConfig = {}) {
|
|
|
277
273
|
}
|
|
278
274
|
}).onBeforeHandle(({ user, set, request }) => {
|
|
279
275
|
const path = new URL(request.url).pathname
|
|
280
|
-
// Verificar se a rota deve ser excluída da autenticação (guard redundante por segurança)
|
|
281
|
-
if (config.excludePaths.some(excluded => path.startsWith(excluded))) {
|
|
282
|
-
return
|
|
283
|
-
}
|
|
284
276
|
|
|
285
|
-
//
|
|
277
|
+
// Verificar se a rota deve ser excluída da autenticação
|
|
278
|
+
const isExcluded = config.excludePaths.some(excluded => path.startsWith(excluded))
|
|
279
|
+
if (isExcluded) return
|
|
280
|
+
|
|
281
|
+
// Bloquear se não houver usuário
|
|
286
282
|
if (!user) {
|
|
287
283
|
return config.onUnauthorized(set)
|
|
288
284
|
}
|