@riligar/auth-elysia 1.6.4 → 1.7.0
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 +11 -1
- package/dist/index.js +11 -1
- package/package.json +1 -1
- package/src/index.js +11 -1
package/dist/index.esm.js
CHANGED
|
@@ -117,7 +117,17 @@ function authPlugin(userConfig = {}) {
|
|
|
117
117
|
.onBeforeHandle({ as: 'global' }, ({ user, set, request }) => {
|
|
118
118
|
const path = new URL(request.url).pathname;
|
|
119
119
|
if (config.excludePaths.some(p => path.startsWith(p))) return
|
|
120
|
-
if (!user)
|
|
120
|
+
if (!user) {
|
|
121
|
+
set.status = 401;
|
|
122
|
+
set.headers['Content-Type'] = 'application/json';
|
|
123
|
+
return {
|
|
124
|
+
success: false,
|
|
125
|
+
error: {
|
|
126
|
+
code: 'UNAUTHORIZED',
|
|
127
|
+
message: 'Sessão inválida ou expirada. Por favor, faça login novamente.',
|
|
128
|
+
},
|
|
129
|
+
}
|
|
130
|
+
}
|
|
121
131
|
})
|
|
122
132
|
.error(({ error, set }) => {
|
|
123
133
|
const errorStr = String(error);
|
package/dist/index.js
CHANGED
|
@@ -121,7 +121,17 @@ function authPlugin(userConfig = {}) {
|
|
|
121
121
|
.onBeforeHandle({ as: 'global' }, ({ user, set, request }) => {
|
|
122
122
|
const path = new URL(request.url).pathname;
|
|
123
123
|
if (config.excludePaths.some(p => path.startsWith(p))) return
|
|
124
|
-
if (!user)
|
|
124
|
+
if (!user) {
|
|
125
|
+
set.status = 401;
|
|
126
|
+
set.headers['Content-Type'] = 'application/json';
|
|
127
|
+
return {
|
|
128
|
+
success: false,
|
|
129
|
+
error: {
|
|
130
|
+
code: 'UNAUTHORIZED',
|
|
131
|
+
message: 'Sessão inválida ou expirada. Por favor, faça login novamente.',
|
|
132
|
+
},
|
|
133
|
+
}
|
|
134
|
+
}
|
|
125
135
|
})
|
|
126
136
|
.error(({ error, set }) => {
|
|
127
137
|
const errorStr = String(error);
|
package/package.json
CHANGED
package/src/index.js
CHANGED
|
@@ -116,7 +116,17 @@ export function authPlugin(userConfig = {}) {
|
|
|
116
116
|
.onBeforeHandle({ as: 'global' }, ({ user, set, request }) => {
|
|
117
117
|
const path = new URL(request.url).pathname
|
|
118
118
|
if (config.excludePaths.some(p => path.startsWith(p))) return
|
|
119
|
-
if (!user)
|
|
119
|
+
if (!user) {
|
|
120
|
+
set.status = 401
|
|
121
|
+
set.headers['Content-Type'] = 'application/json'
|
|
122
|
+
return {
|
|
123
|
+
success: false,
|
|
124
|
+
error: {
|
|
125
|
+
code: 'UNAUTHORIZED',
|
|
126
|
+
message: 'Sessão inválida ou expirada. Por favor, faça login novamente.',
|
|
127
|
+
},
|
|
128
|
+
}
|
|
129
|
+
}
|
|
120
130
|
})
|
|
121
131
|
.error(({ error, set }) => {
|
|
122
132
|
const errorStr = String(error)
|