proto.io 0.0.196 → 0.0.197

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.js CHANGED
@@ -1288,8 +1288,14 @@ const sessionId = (proto, request) => {
1288
1288
  };
1289
1289
  const userCacheMap = new WeakMap;
1290
1290
  const fetchSessionInfo = async (proto, userId) => {
1291
- if (!userId)
1292
- return {};
1291
+ if (!userId) {
1292
+ const user = proto.req ? await proto[_private.PVK].options.userResolver(proto, undefined) : undefined;
1293
+ const _roles = user instanceof index.TUser ? _.filter(await proto.userRoles(user), x => !_.isEmpty(x.name)) : [];
1294
+ return {
1295
+ user: user?.clone(),
1296
+ _roles: _.map(_roles, x => x.clone()),
1297
+ };
1298
+ }
1293
1299
  if (!userCacheMap.has(proto[_private.PVK]))
1294
1300
  userCacheMap.set(proto[_private.PVK], {});
1295
1301
  const cache = userCacheMap.get(proto[_private.PVK]);