@shopgate/pwa-common 7.33.2 → 7.33.3-beta.2

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.
@@ -19,16 +19,24 @@ export const requestLogin = (user, password, strategy = DEFAULT_LOGIN_STRATEGY)
19
19
 
20
20
  /**
21
21
  * Creates the dispatched RECEIVE_LOGIN action object.
22
- * @param {string} redirect The location to redirect to.
22
+ * @param {Object|boolean} [redirect] The redirect params. When set to `false` the user stays on
23
+ * the current page.
23
24
  * @param {string} strategy The login strategy.
24
25
  * @param {number} [sessionLifetimeInSeconds] The session lifetime in seconds
26
+ * @param {Object} [options] Further details of the login.
27
+ * @param {string} [options.source] What the login came from when it wasn't the login form, e.g.
28
+ * `LOGIN_SOURCE_BIOMETRIC` of `@shopgate/engage/login/constants`. Subscriptions can use it to
29
+ * react differently, e.g. to skip a confirmation.
25
30
  * @returns {Object} The dispatched action object.
26
31
  */
27
- export const successLogin = (redirect, strategy = DEFAULT_LOGIN_STRATEGY, sessionLifetimeInSeconds) => ({
32
+ export const successLogin = (redirect, strategy = DEFAULT_LOGIN_STRATEGY, sessionLifetimeInSeconds = undefined, {
33
+ source
34
+ } = {}) => ({
28
35
  type: SUCCESS_LOGIN,
29
36
  redirect,
30
37
  strategy,
31
- sessionLifetimeInSeconds
38
+ sessionLifetimeInSeconds,
39
+ source
32
40
  });
33
41
 
34
42
  /**
@@ -1,38 +1,27 @@
1
- import { PipelineRequest, EINVALIDCALL, ELEGACYSGCONNECT, EINCOMPLETELOGIN } from '@shopgate/pwa-core';
1
+ import { PipelineRequest } from '@shopgate/engage/core/classes';
2
+ import { EINVALIDCALL, ELEGACYSGCONNECT, EINCOMPLETELOGIN } from '@shopgate/engage/core/constants';
3
+ import { getRecaptchaToken } from '@shopgate/engage/core/helpers';
2
4
  import { requestLogin, successLogin, errorLogin, errorLegacyConnectRegister } from "../../action-creators/user";
3
5
  import { SHOPGATE_USER_LOGIN_USER } from "../../constants/Pipelines";
4
6
  import { DEFAULT_LOGIN_STRATEGY } from "../../constants/user";
5
7
  import { mutable } from "../../helpers/redux";
6
- import appConfig from "../../helpers/config";
7
8
 
8
9
  /**
9
10
  * Login the current user.
10
11
  * @param {Object} parameters The login credentials.
11
12
  * @param {string} parameters.login The username to login.
12
13
  * @param {string} parameters.password The password to login.
13
- * @param {string} redirect The location to redirect to when logged in.
14
- * @param {string} strategy basic or facebook, amazon, etc
14
+ * @param {Object|boolean} [redirect] The redirect params, e.g. `{ location }` of the page to open
15
+ * when logged in. When set to `false` the user stays on the current page.
16
+ * @param {string} [strategy] basic or facebook, amazon, etc
15
17
  * @return {Function} A redux thunk.
16
18
  */
17
19
  function login(parameters, redirect, strategy = DEFAULT_LOGIN_STRATEGY) {
18
20
  return async dispatch => {
19
- const {
20
- enabled: recaptchaEnabled,
21
- googleCloudSiteKey
22
- } = appConfig?.recaptcha || {};
23
21
  dispatch(requestLogin(parameters.login, parameters.password, strategy));
24
- let recaptchaToken;
25
- if (recaptchaEnabled && googleCloudSiteKey) {
26
- try {
27
- // Add a reCAPTCHA token to the login request when feature is configured
28
- await new Promise(resolve => window.grecaptcha.enterprise.ready(resolve));
29
- recaptchaToken = await window.grecaptcha.enterprise.execute(googleCloudSiteKey, {
30
- action: 'login'
31
- });
32
- } catch (e) {
33
- // noting to do here - just for protection
34
- }
35
- }
22
+
23
+ // Add a reCAPTCHA token to the login request when feature is configured
24
+ const recaptchaToken = await getRecaptchaToken('login', 0);
36
25
  const request = new PipelineRequest(SHOPGATE_USER_LOGIN_USER).setTrusted().setErrorBlacklist([EINVALIDCALL, ELEGACYSGCONNECT, EINCOMPLETELOGIN]).setInput({
37
26
  strategy,
38
27
  parameters: {
@@ -18,6 +18,9 @@ export const PAGE_LOGIN_AFTER: "page.login.after";
18
18
  export const PAGE_LOGIN_FORM_BEFORE: "page.login.form.before";
19
19
  export const PAGE_LOGIN_FORM: "page.login.form";
20
20
  export const PAGE_LOGIN_FORM_AFTER: "page.login.form.after";
21
+ export const PAGE_LOGIN_FORM_SUBMIT_BEFORE: "page.login.form.submit.before";
22
+ export const PAGE_LOGIN_FORM_SUBMIT: "page.login.form.submit";
23
+ export const PAGE_LOGIN_FORM_SUBMIT_AFTER: "page.login.form.submit.after";
21
24
  export const PAGE_LOGIN_REGISTER_LINK_BEFORE: "page.login.register-link.before";
22
25
  export const PAGE_LOGIN_REGISTER_LINK: "page.login.register-link";
23
26
  export const PAGE_LOGIN_REGISTER_LINK_AFTER: "page.login.register-link.after";
@@ -68,6 +71,9 @@ export const NO_RESULTS_CONTENT_AFTER: "no-results.content.after";
68
71
  export const USER_MENU_CONTAINER_BEFORE: "user-menu.container.before";
69
72
  export const USER_MENU_CONTAINER: "user-menu.container";
70
73
  export const USER_MENU_CONTAINER_AFTER: "user-menu.container.after";
74
+ export const USER_MENU_LOGIN_BEFORE: "user-menu.login.before";
75
+ export const USER_MENU_LOGIN: "user-menu.login";
76
+ export const USER_MENU_LOGIN_AFTER: "user-menu.login.after";
71
77
  export const APP_BAR_DEFAULT_BEFORE: "app-bar.default.before";
72
78
  export const APP_BAR_DEFAULT: "app-bar.default";
73
79
  export const APP_BAR_DEFAULT_AFTER: "app-bar.default.after";
@@ -1 +1 @@
1
- {"version":3,"file":"Portals.d.ts","sourceRoot":"","sources":["../../constants/Portals.js"],"names":[],"mappings":"AAqCA,qBAAsB,QAAQ,CAAC;AAC/B,oBAAqB,OAAO,CAAC;AAC7B,mBAAoB,MAAM,CAAC;AAC3B,qBAAsB,QAAQ,CAAC;AAC/B,oBAAqB,OAAO,CAAC;AAC7B,oBAAqB,OAAO,CAAC;AAE7B,wCAA+C;AAC/C,sCAA6C;AAE7C,wDAAkE;AAClE,0CAAiD;AACjD,sDAAgE;AAEhE,wDAAkE;AAClE,0CAAiD;AACjD,sDAAgE;AAEhE,oDAA8D;AAC9D,sCAA6C;AAC7C,kDAA4D;AAE5D,8DAA2E;AAC3E,gDAA0D;AAC1D,4DAAyE;AAEzE,gFAA6F;AAC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ACvD,4DAAsE;AAEtE,8DAAwE;AACxE,gDAAuD;AACvD,4DAAsE;AAEtE,wDAAkE;AAClE,0CAAiD;AACjD,sDAAgE;AAEhE,0DAAoE;AACpE,4CAAmD;AACnD,wDAAkE;AAElE,4DAAsE;AACtE,8CAAqD;AACrD,0DAAoE;AAEpE,0CAAiD;AACjD,wDAAkE;AAClE,sDAAgE;AAEhE,8CAAqD;AACrD,4DAAsE;AACtE,0DAAoE;AAEpE,4CAAmD;AACnD,0DAAoE;AACpE,wDAAkE;AAElE,4CAAmD;AACnD,0DAAoE;AACpE,wDAAkE;AAElE,wDAA+D;AAC/D,sEAAgF;AAChF,oEAA8E;AAE9E,gDAAuD;AACvD,8DAAqE;AACrE,4DAAmE"}
@@ -33,6 +33,7 @@ const CLOSE = 'close';
33
33
  const SIMPLE = 'simple';
34
34
  const CART_BUTTON = 'cart-button';
35
35
  const ITEMS = 'items';
36
+ const SUBMIT = 'submit';
36
37
 
37
38
  // POSITIONS
38
39
  export const BEFORE = 'before';
@@ -55,6 +56,9 @@ export const PAGE_LOGIN_AFTER = `${PAGE}.${LOGIN}.${AFTER}`;
55
56
  export const PAGE_LOGIN_FORM_BEFORE = `${PAGE}.${LOGIN}.${FORM}.${BEFORE}`;
56
57
  export const PAGE_LOGIN_FORM = `${PAGE}.${LOGIN}.${FORM}`;
57
58
  export const PAGE_LOGIN_FORM_AFTER = `${PAGE}.${LOGIN}.${FORM}.${AFTER}`;
59
+ export const PAGE_LOGIN_FORM_SUBMIT_BEFORE = `${PAGE}.${LOGIN}.${FORM}.${SUBMIT}.${BEFORE}`;
60
+ export const PAGE_LOGIN_FORM_SUBMIT = `${PAGE}.${LOGIN}.${FORM}.${SUBMIT}`;
61
+ export const PAGE_LOGIN_FORM_SUBMIT_AFTER = `${PAGE}.${LOGIN}.${FORM}.${SUBMIT}.${AFTER}`;
58
62
  export const PAGE_LOGIN_REGISTER_LINK_BEFORE = `${PAGE}.${LOGIN}.${REGISTER_LINK}.${BEFORE}`;
59
63
  export const PAGE_LOGIN_REGISTER_LINK = `${PAGE}.${LOGIN}.${REGISTER_LINK}`;
60
64
  export const PAGE_LOGIN_REGISTER_LINK_AFTER = `${PAGE}.${LOGIN}.${REGISTER_LINK}.${AFTER}`;
@@ -105,6 +109,9 @@ export const NO_RESULTS_CONTENT_AFTER = `${NO_RESULTS}.${CONTENT}.${AFTER}`;
105
109
  export const USER_MENU_CONTAINER_BEFORE = `${USER_MENU}.${CONTAINER}.${BEFORE}`;
106
110
  export const USER_MENU_CONTAINER = `${USER_MENU}.${CONTAINER}`;
107
111
  export const USER_MENU_CONTAINER_AFTER = `${USER_MENU}.${CONTAINER}.${AFTER}`;
112
+ export const USER_MENU_LOGIN_BEFORE = `${USER_MENU}.${LOGIN}.${BEFORE}`;
113
+ export const USER_MENU_LOGIN = `${USER_MENU}.${LOGIN}`;
114
+ export const USER_MENU_LOGIN_AFTER = `${USER_MENU}.${LOGIN}.${AFTER}`;
108
115
  export const APP_BAR_DEFAULT_BEFORE = `${APP_BAR}.${DEFAULT}.${BEFORE}`;
109
116
  export const APP_BAR_DEFAULT = `${APP_BAR}.${DEFAULT}`;
110
117
  export const APP_BAR_DEFAULT_AFTER = `${APP_BAR}.${DEFAULT}.${AFTER}`;
@@ -84,7 +84,7 @@ export const mutable = func => {
84
84
 
85
85
  // Execute pre-processing steps, if any available.
86
86
  if (steps.length > 0) {
87
- mutatedArgs = steps.reduce((acc, step, i, arr) => {
87
+ mutatedArgs = steps.slice().reduce((acc, step, i, arr) => {
88
88
  // Call next step func in the pipeline with mutated args
89
89
  let res = step.apply(void 0, acc);
90
90
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shopgate/pwa-common",
3
- "version": "7.33.2",
3
+ "version": "7.33.3-beta.2",
4
4
  "description": "Common library for the Shopgate Connect PWA.",
5
5
  "license": "Apache-2.0",
6
6
  "author": "Shopgate <support@shopgate.com>",
@@ -21,6 +21,7 @@
21
21
  "dependencies": {
22
22
  "@redux-devtools/extension": "^3.3.0",
23
23
  "@sentry/browser": "^7.120.4",
24
+ "@shopgate/native-modules": "1.1.0-alpha.3",
24
25
  "@virtuous/conductor": "~2.5.0",
25
26
  "@virtuous/react-conductor": "~2.5.0",
26
27
  "@virtuous/redux-persister": "1.1.0-beta.7",
@@ -43,7 +44,7 @@
43
44
  "swiper": "12.2.0"
44
45
  },
45
46
  "devDependencies": {
46
- "@shopgate/pwa-core": "7.33.2",
47
+ "@shopgate/pwa-core": "7.33.3-beta.2",
47
48
  "@types/lodash": "^4.17.25",
48
49
  "@types/react-portal": "^3.0.9",
49
50
  "lodash": "^4.18.1",
@@ -3,7 +3,7 @@ import { router, ACTION_POP, ACTION_PUSH, ACTION_REPLACE, ACTION_RESET } from '@
3
3
  import Route from '@virtuous/conductor/Route';
4
4
  import { Linking } from '@shopgate/native-modules';
5
5
  import { HISTORY_RESET_TO } from '@shopgate/pwa-common/constants/ActionTypes';
6
- import { logger } from '@shopgate/pwa-core';
6
+ import { logger } from '@shopgate/engage/core/helpers';
7
7
  import { isNavigationBlocked } from '@shopgate/engage/admin-preview/helpers';
8
8
  import addCouponsToCart from '@shopgate/pwa-common-commerce/cart/actions/addCouponsToCart';
9
9
  import { getCurrentRoute, getRouterStackIndex } from "../selectors/router";
@@ -325,7 +325,7 @@ export default function routerSubscriptions(subscribe) {
325
325
  action,
326
326
  dispatch
327
327
  }) => {
328
- if (appConfig.webCheckoutShopify === null) {
328
+ if (appConfig.webCheckoutShopify === null && action.redirect !== false) {
329
329
  dispatch(historyRedirect(action.redirect));
330
330
  }
331
331
  });