@asaidimu/hestia-mock 1.15.0 → 1.16.1
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/index.cjs +29 -2
- package/index.cjs.map +1 -1
- package/{index.d.ts → index.d.mts} +1 -1
- package/{index.js → index.mjs} +30 -3
- package/index.mjs.map +1 -0
- package/package.json +2 -2
- package/index.js.map +0 -1
package/index.cjs
CHANGED
|
@@ -674,6 +674,10 @@ const OPERATION_POLICIES = [
|
|
|
674
674
|
name: "system:auth:session:delete",
|
|
675
675
|
rule: "authenticated"
|
|
676
676
|
},
|
|
677
|
+
{
|
|
678
|
+
name: "system:auth:session:get",
|
|
679
|
+
rule: "authenticated"
|
|
680
|
+
},
|
|
677
681
|
{
|
|
678
682
|
name: "system:auth:password:reset",
|
|
679
683
|
rule: "anonymous"
|
|
@@ -1251,13 +1255,32 @@ function userHandlers(deps) {
|
|
|
1251
1255
|
if (!email || !password) throw err.invalidCredentials();
|
|
1252
1256
|
const user = await verifyCredentials(tables, email, password);
|
|
1253
1257
|
if (!user) throw err.invalidCredentials();
|
|
1258
|
+
const session = await createSession(tables, user._id_);
|
|
1254
1259
|
ctx.identity = {
|
|
1255
1260
|
user,
|
|
1256
1261
|
auth_method: "password",
|
|
1257
|
-
session_id:
|
|
1262
|
+
session_id: session.token,
|
|
1258
1263
|
is_admin: isAdmin(user)
|
|
1259
1264
|
};
|
|
1260
|
-
return ok({
|
|
1265
|
+
return ok({
|
|
1266
|
+
user: sanitizeUser(clone(user)),
|
|
1267
|
+
expires_at: Math.floor(session.expires_at / 1e3)
|
|
1268
|
+
});
|
|
1269
|
+
}
|
|
1270
|
+
},
|
|
1271
|
+
"system:auth:session:get": {
|
|
1272
|
+
access: "authenticated",
|
|
1273
|
+
handler: async (ctx) => {
|
|
1274
|
+
const identity = ctx.identity;
|
|
1275
|
+
let expiresAt = null;
|
|
1276
|
+
if (identity.session_id) {
|
|
1277
|
+
const session = await tables.sessions.get(identity.session_id);
|
|
1278
|
+
expiresAt = session ? Math.floor(session.expires_at / 1e3) : null;
|
|
1279
|
+
}
|
|
1280
|
+
return ok({
|
|
1281
|
+
user: sanitizeUser(clone(identity.user)),
|
|
1282
|
+
expires_at: expiresAt
|
|
1283
|
+
});
|
|
1261
1284
|
}
|
|
1262
1285
|
},
|
|
1263
1286
|
"system:auth:session:delete": {
|
|
@@ -3209,6 +3232,10 @@ const MOCK_ROUTE_TABLE = {
|
|
|
3209
3232
|
method: "DELETE",
|
|
3210
3233
|
route: "/system/auth/session/delete"
|
|
3211
3234
|
},
|
|
3235
|
+
"system:auth:session:get": {
|
|
3236
|
+
method: "GET",
|
|
3237
|
+
route: "/system/auth/session/get"
|
|
3238
|
+
},
|
|
3212
3239
|
"system:auth:token:elevate": {
|
|
3213
3240
|
method: "POST",
|
|
3214
3241
|
route: "/system/auth/token/elevate"
|