@linzjs/lui 17.9.4 → 17.10.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/CHANGELOG.md CHANGED
@@ -1,3 +1,10 @@
1
+ # [17.10.0](https://github.com/linz/lui/compare/v17.9.4...v17.10.0) (2022-08-12)
2
+
3
+
4
+ ### Features
5
+
6
+ * **LOLLogoutLink:** TITLE-795 added logout guard 'preventLogout', so apps can do before logout check. ([#720](https://github.com/linz/lui/issues/720)) ([4d36fdb](https://github.com/linz/lui/commit/4d36fdb5c1fdf714ec7aede4319a2e38566670ea))
7
+
1
8
  ## [17.9.4](https://github.com/linz/lui/compare/v17.9.3...v17.9.4) (2022-08-11)
2
9
 
3
10
  ## [17.9.3](https://github.com/linz/lui/compare/v17.9.2...v17.9.3) (2022-08-11)
@@ -1,6 +1,7 @@
1
1
  /// <reference types="react" />
2
2
  export interface Props {
3
3
  redirectPath: () => string;
4
- callBackBeforeLogout?: () => Promise<void>;
4
+ /** Return false if the logout should be aborted. */
5
+ callBackBeforeLogout?: () => Promise<void | boolean>;
5
6
  }
6
7
  export declare const LOLLogoutLink: (props: Props) => JSX.Element | null;
package/dist/index.js CHANGED
@@ -29033,18 +29033,23 @@ var LOLLogoutLink = function (props) {
29033
29033
  return null;
29034
29034
  }
29035
29035
  var logout = function () { return __awaiter(void 0, void 0, void 0, function () {
29036
- var res;
29037
- return __generator(this, function (_a) {
29038
- switch (_a.label) {
29036
+ var _a, res;
29037
+ return __generator(this, function (_b) {
29038
+ switch (_b.label) {
29039
29039
  case 0:
29040
- if (!props.callBackBeforeLogout) return [3 /*break*/, 2];
29040
+ _a = props.callBackBeforeLogout;
29041
+ if (!_a) return [3 /*break*/, 2];
29041
29042
  return [4 /*yield*/, props.callBackBeforeLogout()];
29042
29043
  case 1:
29043
- _a.sent();
29044
- _a.label = 2;
29045
- case 2: return [4 /*yield*/, fetch('/auth/api/logout')];
29044
+ _a = (_b.sent()) === false;
29045
+ _b.label = 2;
29046
+ case 2:
29047
+ if (_a) {
29048
+ return [2 /*return*/];
29049
+ }
29050
+ return [4 /*yield*/, fetch('/auth/api/logout')];
29046
29051
  case 3:
29047
- res = _a.sent();
29052
+ res = _b.sent();
29048
29053
  if (res.status === 200) {
29049
29054
  window.location.assign("/auth/login?redirectPath=" + redirectPathString);
29050
29055
  }