@monocloud/auth-nextjs 0.1.4 → 0.1.5

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.
@@ -1,4 +1,4 @@
1
- import { i as ExtraAuthParams } from "../types-DOfZTKa6.mjs";
1
+ import { i as ExtraAuthParams } from "../types-CsBjAJce.mjs";
2
2
  import React, { JSX } from "react";
3
3
 
4
4
  //#region src/components/signin.d.ts
package/dist/index.cjs CHANGED
@@ -459,7 +459,7 @@ var MonoCloudNextClient = class {
459
459
  constructor(options) {
460
460
  const opt = {
461
461
  ...options ?? {},
462
- userAgent: (options === null || options === void 0 ? void 0 : options.userAgent) ?? `@monocloud/auth-nextjs@0.1.4`,
462
+ userAgent: (options === null || options === void 0 ? void 0 : options.userAgent) ?? `@monocloud/auth-nextjs@0.1.5`,
463
463
  debugger: (options === null || options === void 0 ? void 0 : options.debugger) ?? "@monocloud:auth-nextjs"
464
464
  };
465
465
  this.registerPublicEnvVariables();
@@ -578,7 +578,7 @@ var MonoCloudNextClient = class {
578
578
  return redirect(signInRoute.toString());
579
579
  }
580
580
  if ((options === null || options === void 0 ? void 0 : options.groups) && !(0, _monocloud_auth_node_core_utils.isUserInGroup)(session.user, options.groups, options.groupsClaim ?? process.env.MONOCLOUD_AUTH_GROUPS_CLAIM, options.matchAll)) {
581
- if (options.onAccessDenied) return options.onAccessDenied({
581
+ if (options.onGroupAccessDenied) return options.onGroupAccessDenied({
582
582
  ...params,
583
583
  user: session.user
584
584
  });
@@ -620,11 +620,11 @@ var MonoCloudNextClient = class {
620
620
  } };
621
621
  }
622
622
  if ((options === null || options === void 0 ? void 0 : options.groups) && !(0, _monocloud_auth_node_core_utils.isUserInGroup)(session.user, options.groups, options.groupsClaim ?? process.env.MONOCLOUD_AUTH_GROUPS_CLAIM, options.matchAll)) {
623
- var _options$onAccessDeni;
624
- const customProps$1 = await ((_options$onAccessDeni = options.onAccessDenied) === null || _options$onAccessDeni === void 0 ? void 0 : _options$onAccessDeni.call(options, {
623
+ var _options$onGroupAcces;
624
+ const customProps$1 = await ((_options$onGroupAcces = options.onGroupAccessDenied) === null || _options$onGroupAcces === void 0 ? void 0 : _options$onGroupAcces.call(options, {
625
625
  ...context,
626
626
  user: session.user
627
- })) ?? { props: { accessDenied: true } };
627
+ })) ?? { props: { groupAccessDenied: true } };
628
628
  return {
629
629
  ...customProps$1,
630
630
  props: { ...customProps$1.props ?? {} }
@@ -666,8 +666,8 @@ var MonoCloudNextClient = class {
666
666
  return mergeResponse([res, next_server_js.NextResponse.json({ message: "unauthorized" }, { status: 401 })]);
667
667
  }
668
668
  if ((options === null || options === void 0 ? void 0 : options.groups) && !(0, _monocloud_auth_node_core_utils.isUserInGroup)(session.user, options.groups, options.groupsClaim ?? process.env.MONOCLOUD_AUTH_GROUPS_CLAIM, options.matchAll)) {
669
- if (options.onAccessDenied) {
670
- const result = await options.onAccessDenied(req, ctx);
669
+ if (options.onGroupAccessDenied) {
670
+ const result = await options.onGroupAccessDenied(req, ctx, session.user);
671
671
  if (result instanceof next_server_js.NextResponse) return mergeResponse([res, result]);
672
672
  return mergeResponse([res, new next_server_js.NextResponse(result.body, result)]);
673
673
  }
@@ -684,7 +684,7 @@ var MonoCloudNextClient = class {
684
684
  return res.status(401).json({ message: "unauthorized" });
685
685
  }
686
686
  if ((options === null || options === void 0 ? void 0 : options.groups) && !(0, _monocloud_auth_node_core_utils.isUserInGroup)(session.user, options.groups, options.groupsClaim ?? process.env.MONOCLOUD_AUTH_GROUPS_CLAIM, options.matchAll)) {
687
- if (options.onAccessDenied) return options.onAccessDenied(req, res, session.user);
687
+ if (options.onGroupAccessDenied) return options.onGroupAccessDenied(req, res, session.user);
688
688
  return res.status(403).json({ message: "forbidden" });
689
689
  }
690
690
  return handler(req, res);
@@ -748,10 +748,9 @@ var MonoCloudNextClient = class {
748
748
  return mergeResponse([nxtResp, next_server_js.NextResponse.redirect(signInRoute)]);
749
749
  }
750
750
  const groupsClaim = (options === null || options === void 0 ? void 0 : options.groupsClaim) ?? process.env.MONOCLOUD_AUTH_GROUPS_CLAIM;
751
- const onAccessDenied = options === null || options === void 0 ? void 0 : options.onAccessDenied;
752
751
  if (allowedGroups && !(0, _monocloud_auth_node_core_utils.isUserInGroup)(session.user, allowedGroups, groupsClaim)) {
753
- if (onAccessDenied) {
754
- const result = await onAccessDenied(req, evt, session.user);
752
+ if (options === null || options === void 0 ? void 0 : options.onGroupAccessDenied) {
753
+ const result = await options.onGroupAccessDenied(req, evt, session.user);
755
754
  if (result instanceof next_server_js.NextResponse) return mergeResponse([nxtResp, result]);
756
755
  if (result) return mergeResponse([nxtResp, new next_server_js.NextResponse(result.body, result)]);
757
756
  return next_server_js.NextResponse.next(nxtResp);