@saasquatch/mint-components 1.8.5-2 → 1.8.5-20
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/cjs/sqm-big-stat_38.cjs.entry.js +2 -2
- package/dist/cjs/{sqm-portal-verify-email-view-ce552bbc.js → sqm-portal-verify-email-view-1ae5724a.js} +3 -1
- package/dist/cjs/sqm-portal-verify-email.cjs.entry.js +75 -31
- package/dist/cjs/sqm-stencilbook.cjs.entry.js +5 -3
- package/dist/collection/components/sqm-link-button/sqm-link-button-view.js +2 -2
- package/dist/collection/components/sqm-portal-verify-email/PortalVerifyEmail.stories.js +2 -0
- package/dist/collection/components/sqm-portal-verify-email/sqm-portal-verify-email-view.js +3 -1
- package/dist/collection/components/sqm-portal-verify-email/sqm-portal-verify-email.js +1 -1
- package/dist/collection/components/sqm-portal-verify-email/usePortalVerifyEmail.js +76 -32
- package/dist/esm/sqm-big-stat_38.entry.js +2 -2
- package/dist/esm/{sqm-portal-verify-email-view-283bf637.js → sqm-portal-verify-email-view-279b4e58.js} +3 -1
- package/dist/esm/sqm-portal-verify-email.entry.js +77 -33
- package/dist/esm/sqm-stencilbook.entry.js +5 -3
- package/dist/esm-es5/sqm-big-stat_38.entry.js +1 -1
- package/dist/esm-es5/sqm-portal-verify-email-view-279b4e58.js +1 -0
- package/dist/esm-es5/sqm-portal-verify-email.entry.js +1 -1
- package/dist/esm-es5/sqm-stencilbook.entry.js +1 -1
- package/dist/mint-components/mint-components.esm.js +1 -1
- package/dist/mint-components/p-07fc5950.system.entry.js +1 -0
- package/dist/mint-components/{p-561262cd.entry.js → p-1a5005fe.entry.js} +1 -1
- package/dist/mint-components/p-44b12b2e.system.js +1 -1
- package/dist/mint-components/p-64443c35.entry.js +9 -0
- package/dist/mint-components/p-6d60c9aa.system.entry.js +1 -0
- package/dist/mint-components/p-9591961b.entry.js +1 -0
- package/dist/mint-components/p-a40d2ed3.system.js +1 -0
- package/dist/mint-components/{p-907c3344.system.entry.js → p-a9482c97.system.entry.js} +1 -1
- package/dist/mint-components/p-b9d010e0.js +1 -0
- package/dist/types/components/sqm-portal-verify-email/sqm-portal-verify-email-view.d.ts +1 -0
- package/dist/types/components/sqm-portal-verify-email/usePortalVerifyEmail.d.ts +1 -0
- package/docs/docs.docx +0 -0
- package/package.json +1 -1
- package/dist/esm-es5/sqm-portal-verify-email-view-283bf637.js +0 -1
- package/dist/mint-components/p-0a01c91f.entry.js +0 -1
- package/dist/mint-components/p-29b13845.system.entry.js +0 -1
- package/dist/mint-components/p-4d9744bf.js +0 -1
- package/dist/mint-components/p-5cd6d4ed.system.entry.js +0 -1
- package/dist/mint-components/p-b2b22a2a.entry.js +0 -9
- package/dist/mint-components/p-d4b174e1.system.js +0 -1
|
@@ -1508,8 +1508,8 @@ function LinkButtonView(props) {
|
|
|
1508
1508
|
index.h("style", { type: "text/css" },
|
|
1509
1509
|
styleString$1,
|
|
1510
1510
|
vanillaStyle),
|
|
1511
|
-
index.h("sl-button", { type: "primary", exportparts: "base: primarybutton-base" },
|
|
1512
|
-
index.h("a", {
|
|
1511
|
+
index.h("sl-button", { onClick: onClick, type: "primary", exportparts: "base: primarybutton-base" },
|
|
1512
|
+
index.h("a", { class: sheet$1.classes.Link, part: "sqm-link" }, buttonText))));
|
|
1513
1513
|
}
|
|
1514
1514
|
|
|
1515
1515
|
const LinkButton = class {
|
|
@@ -24,7 +24,9 @@ const sheet = JSS.createStyleSheet(style);
|
|
|
24
24
|
const styleString = sheet.toString();
|
|
25
25
|
function PortalVerifyEmailView(props) {
|
|
26
26
|
const { states, data, callbacks, content } = props;
|
|
27
|
-
if (states.
|
|
27
|
+
if (states.loading)
|
|
28
|
+
return;
|
|
29
|
+
if (states.success) {
|
|
28
30
|
return (index.h("div", { class: sheet.classes.Wrapper, part: "sqm-base" },
|
|
29
31
|
index.h("style", { type: "text/css" },
|
|
30
32
|
vanillaStyle,
|
|
@@ -10,7 +10,7 @@ require('./mixins-fe9d4112.js');
|
|
|
10
10
|
require('./JSS-8503a151.js');
|
|
11
11
|
const utils = require('./utils-6847bc06.js');
|
|
12
12
|
require('./sqm-text-span-view-e1cd9bd3.js');
|
|
13
|
-
const sqmPortalVerifyEmailView = require('./sqm-portal-verify-email-view-
|
|
13
|
+
const sqmPortalVerifyEmailView = require('./sqm-portal-verify-email-view-1ae5724a.js');
|
|
14
14
|
|
|
15
15
|
const SUBMITTED_CONTEXT = "sq:verify-submitted";
|
|
16
16
|
function setSubmitted(submitted) {
|
|
@@ -18,18 +18,31 @@ function setSubmitted(submitted) {
|
|
|
18
18
|
window[SUBMITTED_CONTEXT] = submitted;
|
|
19
19
|
}
|
|
20
20
|
function usePortalVerifyEmail({ nextPage, failedPage, verifySuccessText, verifyEmailText, verifyInvalidText, networkErrorMessage, continueText, }) {
|
|
21
|
-
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
21
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
22
22
|
const submitted = window[SUBMITTED_CONTEXT];
|
|
23
|
-
const userIdent =
|
|
23
|
+
// const userIdent = useUserIdentity();
|
|
24
|
+
const [verificationError, setVerificationError] = stencilHooks_module.useState(null);
|
|
25
|
+
const [success, setSuccess] = stencilHooks_module.useState(false);
|
|
24
26
|
const [request, { loading, data, errors }] = index_module.an();
|
|
25
27
|
const urlParams = new URLSearchParams(index_module.$n.location.search);
|
|
26
28
|
const oobCode = urlParams.get("oobCode");
|
|
29
|
+
const oobEmail = urlParams.get("email");
|
|
27
30
|
const nextPageOverride = urlParams.get("nextPage");
|
|
28
31
|
// derived from useMutation in component boilerplate initialState
|
|
29
32
|
const disableContinue = data === undefined && errors === undefined && !!oobCode;
|
|
30
33
|
// if logged out, userIdent?.managedIdentity?.emailVerified will be falsey, even if verification was successful
|
|
31
|
-
const
|
|
32
|
-
|
|
34
|
+
const userIdentContext = localStorage.getItem("sq:user-identity");
|
|
35
|
+
const userIdent = getUserIdent(userIdentContext);
|
|
36
|
+
const email = (_a = userIdent === null || userIdent === void 0 ? void 0 : userIdent.managedIdentity) === null || _a === void 0 ? void 0 : _a.email;
|
|
37
|
+
const verified = !!(((_b = userIdent === null || userIdent === void 0 ? void 0 : userIdent.managedIdentity) === null || _b === void 0 ? void 0 : _b.emailVerified) || (data === null || data === void 0 ? void 0 : data.verifyManagedIdentityEmail.success));
|
|
38
|
+
function getUserIdent(context) {
|
|
39
|
+
try {
|
|
40
|
+
return JSON.parse(context);
|
|
41
|
+
}
|
|
42
|
+
catch {
|
|
43
|
+
return undefined;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
33
46
|
const failed = () => {
|
|
34
47
|
return index_module.$n.push({
|
|
35
48
|
pathname: failedPage,
|
|
@@ -41,47 +54,78 @@ function usePortalVerifyEmail({ nextPage, failedPage, verifySuccessText, verifyE
|
|
|
41
54
|
const url = utils.sanitizeUrlPath(nextPageOverride || nextPage);
|
|
42
55
|
index_module.$n.push(url.href);
|
|
43
56
|
};
|
|
57
|
+
const logout = () => {
|
|
58
|
+
console.debug("LOGOUT");
|
|
59
|
+
setTimeout(() => {
|
|
60
|
+
gotoNextPage();
|
|
61
|
+
index_module.setUserIdentity(undefined);
|
|
62
|
+
setSubmitted(false);
|
|
63
|
+
}, 3000);
|
|
64
|
+
};
|
|
44
65
|
const submit = async () => {
|
|
45
|
-
var _a;
|
|
66
|
+
var _a, _b;
|
|
46
67
|
setSubmitted(true);
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
68
|
+
const response = await request({ oobCode });
|
|
69
|
+
if (response instanceof Error ||
|
|
70
|
+
!((_a = response === null || response === void 0 ? void 0 : response.verifyManagedIdentityEmail) === null || _a === void 0 ? void 0 : _a.success)) {
|
|
71
|
+
setVerificationError({ message: true });
|
|
72
|
+
}
|
|
73
|
+
else if ((_b = response === null || response === void 0 ? void 0 : response.verifyManagedIdentityEmail) === null || _b === void 0 ? void 0 : _b.success) {
|
|
74
|
+
setSuccess(true);
|
|
75
|
+
}
|
|
76
|
+
if (email && email !== oobEmail) {
|
|
77
|
+
console.debug("email mismatch", { response });
|
|
78
|
+
logout();
|
|
79
|
+
return;
|
|
59
80
|
}
|
|
81
|
+
console.debug("SUBMITTED", response);
|
|
60
82
|
};
|
|
61
83
|
stencilHooks_module.useEffect(() => {
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
if (verified && !((_a = userIdent === null || userIdent === void 0 ? void 0 : userIdent.managedIdentity) === null || _a === void 0 ? void 0 : _a.emailVerified)) {
|
|
66
|
-
index_module.setUserIdentity(undefined);
|
|
67
|
-
gotoNextPage();
|
|
68
|
-
// Already verified, begin redirect
|
|
69
|
-
}
|
|
70
|
-
else if (verified) {
|
|
84
|
+
console.log({ verified, userIdent });
|
|
85
|
+
if (verified) {
|
|
86
|
+
setSuccess(true);
|
|
71
87
|
setTimeout(() => {
|
|
72
88
|
gotoNextPage();
|
|
89
|
+
index_module.setUserIdentity(undefined);
|
|
73
90
|
setSubmitted(false);
|
|
74
91
|
}, 3000);
|
|
75
|
-
return;
|
|
76
92
|
}
|
|
77
|
-
if (
|
|
93
|
+
else if (!data && !submitted && oobCode)
|
|
78
94
|
submit();
|
|
79
95
|
}, [verified, submitted, data, userIdent]);
|
|
96
|
+
// console.log({ hasContext, userIdent, data, submitted, verified, errors });
|
|
97
|
+
// useEffect(() => {
|
|
98
|
+
// if (errors && !verified) setVerificationError(errors);
|
|
99
|
+
// }, [errors, verified]);
|
|
100
|
+
// useEffect(() => {
|
|
101
|
+
// if (!data && !submitted && oobCode) submit();
|
|
102
|
+
// // verification successful but user in context is not verified
|
|
103
|
+
// // or mismatch between logged in user and user associated with oobCode
|
|
104
|
+
// if (submitted) {
|
|
105
|
+
// console.debug("in submit condition");
|
|
106
|
+
// if (email && email !== oobEmail) {
|
|
107
|
+
// console.debug("email mismatch");
|
|
108
|
+
// logout();
|
|
109
|
+
// return;
|
|
110
|
+
// // Already verified, begin redirect
|
|
111
|
+
// }
|
|
112
|
+
// if (verified) {
|
|
113
|
+
// if (!verificationError) setSuccess(true);
|
|
114
|
+
// console.debug("verified");
|
|
115
|
+
// setTimeout(() => {
|
|
116
|
+
// gotoNextPage();
|
|
117
|
+
// setSubmitted(false);
|
|
118
|
+
// }, 3000);
|
|
119
|
+
// return;
|
|
120
|
+
// }
|
|
121
|
+
// }
|
|
122
|
+
// }, [submitted, verificationError, data, email, oobCode, oobEmail, submit]);
|
|
80
123
|
return {
|
|
81
124
|
states: {
|
|
82
125
|
loading: loading || disableContinue,
|
|
83
|
-
|
|
84
|
-
|
|
126
|
+
success,
|
|
127
|
+
error: ((_f = (_e = (_d = (_c = verificationError === null || verificationError === void 0 ? void 0 : verificationError.response) === null || _c === void 0 ? void 0 : _c.errors) === null || _d === void 0 ? void 0 : _d[0]) === null || _e === void 0 ? void 0 : _e.extensions) === null || _f === void 0 ? void 0 : _f.message) || ((_j = (_h = (_g = verificationError === null || verificationError === void 0 ? void 0 : verificationError.response) === null || _g === void 0 ? void 0 : _g.errors) === null || _h === void 0 ? void 0 : _h[0]) === null || _j === void 0 ? void 0 : _j.message) ||
|
|
128
|
+
((verificationError === null || verificationError === void 0 ? void 0 : verificationError.message) && networkErrorMessage),
|
|
85
129
|
verified,
|
|
86
130
|
},
|
|
87
131
|
data: {
|
|
@@ -27,7 +27,7 @@ const sqmPortalForgotPasswordView = require('./sqm-portal-forgot-password-view-c
|
|
|
27
27
|
const sqmPortalProfileView = require('./sqm-portal-profile-view-d8697f23.js');
|
|
28
28
|
require('./utilities-73df97e1.js');
|
|
29
29
|
const sqmPortalResetPasswordView = require('./sqm-portal-reset-password-view-07a13210.js');
|
|
30
|
-
const sqmPortalVerifyEmailView = require('./sqm-portal-verify-email-view-
|
|
30
|
+
const sqmPortalVerifyEmailView = require('./sqm-portal-verify-email-view-1ae5724a.js');
|
|
31
31
|
const ShadowViewAddon = require('./ShadowViewAddon-89ba2ab0.js');
|
|
32
32
|
const sqmPortalContainerView = require('./sqm-portal-container-view-5fb2ad49.js');
|
|
33
33
|
const sqmInvoiceTableView = require('./sqm-invoice-table-view-501f8985.js');
|
|
@@ -7605,7 +7605,7 @@ const PortalResetPassword = /*#__PURE__*/Object.freeze({
|
|
|
7605
7605
|
CodeValidating: CodeValidating
|
|
7606
7606
|
});
|
|
7607
7607
|
|
|
7608
|
-
const scenario$9 = "@author:derek\n@owner:ian\nFeature: Verify Email\n\n
|
|
7608
|
+
const scenario$9 = "@author:derek\n@owner:ian\nFeature: Verify Email\n\n Background: A user is on the email verification page\n Given a user who has been redirected to the email verification page\n\n @motivating\n Scenario: Verifying your email takes you to the portal login page\n Given a user has a valid oob code as a url query parameter\n When they click \"Verify Email\"\n Then the button enters a loading state\n When their email is validated\n Then a button that says \"Continue\" appears\n When they click \"Continue\"\n Then they are redirected to login\n\n @motivating\n Scenario: Users are automatically redirected if they dont click \"Continue\"\n Given a user has a valid oob code as a url query parameter\n When they click \"Verify Email\"\n Then the button enters a loading state\n When their email is validated\n Then a button that says \"Continue\" appears\n When they wait 5 seconds\n Then they are redirected to login\n\n @motivating\n Scenario: Users are notified if verifying their email has failed\n Given a user has a valid oob code as a url query parameter\n When they click \"Verify Email\"\n Then the button enters a loading state\n When their email fails to be validated\n Then an banner is shown stating that an error occured\n\n @motivating\n Scenario Outline: Users cannot verify their email with an invalid or missing oob code\n Given a user has a <oobCode> as a url query parameter\n And the component <mayHave> \"failed-page\" with <value>\n Then they see an error message saying that their verification code is invalid/expired\n When they click \"Continue\"\n Then they are redirected to <redirectPath>\n Examples:\n | oobCode | mayHave | value | redirectPath |\n | invalid oob code | doesn't have | N/A | / |\n | non existant oob code | doesn't have | N/A | / |\n | invalid oob code | has | /login | /login |\n | non existant oob code | has | /login | /login |\n\n @motivating\n Scenario: Users are redirected to \"/\" by default\n Given the component does not have prop \"nextPage\"\n And the users url does not contain a \"nextPage\" query parameter\n And a user has verified their email\n When they click \"Continue\"\n Then they are redirected to \"/\"\n\n @motivating\n Scenario: Custom redirection can be configured\n Given the component has prop \"nextPage\" with value \"/activity\"\n And the users url does not contain a \"nextPage\" query parameter\n And a user has verified their email\n When they click \"Continue\"\n Then they are redirected to \"/activity\"\n\n @motivating\n Scenario Outline: Users are redirected to the value of the nextPage url parameter if it exists\n Given the component <mayHave> prop \"nextPage\" with <nextPageValue>\n And the users url contains a \"nextPage\" query paramater with <nextPageParamValue>\n And the user has verified their email\n When they click \"Continue\"\n Then they are redirected to <nextPageParamValue>\n Examples:\n | mayHave | nextPageValue | nextPageParamValue |\n | has | /dashboard | /activity |\n | does not have | N/A | /activity |\n\n @motivating\n Scenario Outline: Users are redirected to the value of the nextPage url parameter as if it were a relative path\n Given the component is loaded at <currentUrl>\n And the user has verified their email\n When they click \"Continue\"\n And they are redirected to <url>\n Examples:\n | currentUrl | url |\n | https://www.example.com?nextPage=./activity | https://www.example.com/activity |\n | https://www.example.com?nextPage=activity | https://www.example.com/activity |\n | https://www.example.com?nextPage=/activity | https://www.example.com/activity |\n | https://www.example.com?nextPage=www.google.com | https://www.example.com/www.google.com |\n | https://www.example.com?nextPage=//foo.com | https://www.example.com/ |\n | https://www.example.com?nextPage=https://malicious.example.com | https://www.example.com/ |\n | http://www.example.com/nest/page?oob=123&other&nextPage=activity#heading-1 | http://www.example.com/activity |\n | https://www.example.com?nextPage=activity?foo=bar | https://www.example.com/activity?foo=bar |\n | https://www.example.com?nextPage=%2Factivity%3Ffoo%3Dbar | https://www.example.com/activity?foo=bar |\n | https://www.example.com?nextPage=%2Factivity%3Ffoo%3Dbar#hash | https://www.example.com/activity?foo=bar |\n | https://www.example.com?nextPage=%2Factivity%3Ffoo%3Dbar%23hash | https://www.example.com/activity?foo=bar#hash |\n | https://www.example.com:1337?nextPage=activity | https://www.example.com:1337/activity |\n | http://1.1.1.1:1111?nextPage=activity | http://1.1.1.1:1111/activity |\n\n @landmine\n Scenario Outline: Username and password are not persisted on redirects\n Given the component is loaded at <currentUrl>\n And the user has verified their email\n When they click \"Continue\"\n And they are redirected to <url>\n Examples:\n | currentUrl | url |\n | https://user:pass@www.example.com:444?nextPage=activity | https://www.example.com:444/activity |\n\n\n @minutia\n Scenario Outline: Users may be logged in or logged out depending on the verified status and logged in email\n Given an oobCode with email <oobCodeEmail> as a url query parameter\n And the user is logged in as <loggedInEmail>\n And the logged in user <isVerified>\n When the oobCode is submitted\n And the oobCode <isValid>\n Then the <submitState> screen is shown\n And after 3 seconds pass\n Then the user is redirected to <redirect>\n Examples:\n | oobCodeEmail | loggedInEmail | isVerified | isValid | submitState | redirect |\n | user1@example.com | N/A | false | is valid | success | /login |\n | user1@example.com | N/A | false | is not valid | error | /login |\n | user1@example.com | user1@example.com | false | is valid | success | /activity |\n | user1@example.com | user1@example.com | false | is not valid | error | N/A |\n | user1@example.com | user2@example.com | false | is valid | success | /login |\n | user1@example.com | user2@example.com | false | is not valid | error | /login |\n | user1@example.com | user1@example.com | true | is valid | success | /activity |\n | user1@example.com | user1@example.com | true | is not valid | success | /activity |\n | user1@example.com | user2@example.com | true | is not valid | error | /login |\n | N/A | N/A | false | is not valid | error | N/A |\n";
|
|
7609
7609
|
|
|
7610
7610
|
const PortalVerifyEmail_stories = {
|
|
7611
7611
|
title: "Components/Microsite Verify Email",
|
|
@@ -7618,6 +7618,7 @@ const errorProps$5 = {
|
|
|
7618
7618
|
error: "Something went wrong. Please try again.",
|
|
7619
7619
|
loading: false,
|
|
7620
7620
|
verified: false,
|
|
7621
|
+
success: false,
|
|
7621
7622
|
},
|
|
7622
7623
|
data: {
|
|
7623
7624
|
oobCode: "abc123",
|
|
@@ -7637,6 +7638,7 @@ const verifiedProps = {
|
|
|
7637
7638
|
error: "",
|
|
7638
7639
|
loading: false,
|
|
7639
7640
|
verified: true,
|
|
7641
|
+
success: true,
|
|
7640
7642
|
},
|
|
7641
7643
|
data: {
|
|
7642
7644
|
oobCode: "abc123",
|
|
@@ -9955,7 +9957,7 @@ const ResetPasswordReadme = "# sqm-portal-reset-password\n\n\n\n<!-- Auto Genera
|
|
|
9955
9957
|
|
|
9956
9958
|
const EmailVerificationReadme = "# sqm-portal-email-verification\n\n\n\n<!-- Auto Generated Below -->\n\n\n## Properties\n\n| Property | Attribute | Description | Type | Default |\n| ---------------------------- | ------------------------------ | ----------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| `demoData` | -- | | `{ states?: { error: string; loading: boolean; success: boolean; isVerified?: boolean; loadingVerification?: boolean; countdown?: number; }; content?: { email: string; verifyMessage: string; emailVerificationHeader: string; resendEmailButtonText: string; verificationStatusMessage?: string; verificationLoadingMessage?: string; verificationResentMessage?: string; }; }` | `undefined` |\n| `emailVerificationHeader` | `email-verification-header` | | `string` | `\"Verify your email\"` |\n| `networkErrorMessage` | `network-error-message` | | `string` | `\"An error occurred while verifying your password. Please refresh the page.\"` |\n| `redirectPath` | `redirect-path` | Redirect participants to this page from their verification email. | `string` | `\"/verifyEmail\"` |\n| `resendEmailButtonText` | `resend-email-button-text` | | `string` | `\"Re-send Email\"` |\n| `verificationLoadingMessage` | `verification-loading-message` | | `string` | `\"Checking verification status\"` |\n| `verificationResentMessage` | `verification-resent-message` | | `string` | `\"Your verification email has been resent successfully\"` |\n| `verificationStatusMessage` | `verification-status-message` | | `string` | `\"Checking verification status in {countdown}\"` |\n| `verifyMessage` | `verify-message` | | `string` | `\"A verification email was sent to {email}. Please verify your email to continue to the portal. Resending an email will invalidate the previous email.\"` |\n\n\n## Dependencies\n\n### Depends on\n\n- [sqm-form-message](../sqm-form-message)\n\n### Graph\n```mermaid\ngraph TD;\n sqm-portal-email-verification --> sqm-form-message\n style sqm-portal-email-verification fill:#f9f,stroke:#333,stroke-width:4px\n```\n\n----------------------------------------------\n\n*Built with [StencilJS](https://stenciljs.com/)*\n";
|
|
9957
9959
|
|
|
9958
|
-
const EmailVerifiedReadme = "# sqm-portal-verify-email\n\n\n\n<!-- Auto Generated Below -->\n\n\n## Properties\n\n| Property | Attribute | Description | Type
|
|
9960
|
+
const EmailVerifiedReadme = "# sqm-portal-verify-email\n\n\n\n<!-- Auto Generated Below -->\n\n\n## Properties\n\n| Property | Attribute | Description | Type | Default |\n| --------------------- | ----------------------- | ------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------- |\n| `continueText` | `continue-text` | | `string` | `\"Continue\"` |\n| `demoData` | -- | | `{ states?: { error: string; loading: boolean; success: boolean; verified: boolean; }; data?: { oobCode: string; }; content?: { verifySuccessText?: string; verifyEmailText?: string; verifyInvalidText?: string; continueText?: string; }; }` | `undefined` |\n| `failedPage` | `failed-page` | Redirect participants to this page if verification fails due to an outdated verification attempt. | `string` | `\"/\"` |\n| `networkErrorMessage` | `network-error-message` | | `string` | `\"An error occurred while verifying your email. Please refresh the page and try again.\"` |\n| `nextPage` | `next-page` | Redirect participants to this page when they successfully verify their email. | `string` | `\"/\"` |\n| `verifyEmailText` | `verify-email-text` | | `string` | `\"Verify your email\"` |\n| `verifyInvalidText` | `verify-invalid-text` | | `string` | `\"The email verification code is invalid or has expired, please try again.\"` |\n| `verifySuccessText` | `verify-success-text` | | `string` | `\"Your email has been verified and you are being redirected. If you are not redirected, please click Continue.\"` |\n\n\n## Dependencies\n\n### Depends on\n\n- [sqm-form-message](../sqm-form-message)\n\n### Graph\n```mermaid\ngraph TD;\n sqm-portal-verify-email --> sqm-form-message\n style sqm-portal-verify-email fill:#f9f,stroke:#333,stroke-width:4px\n```\n\n----------------------------------------------\n\n*Built with [StencilJS](https://stenciljs.com/)*\n";
|
|
9959
9961
|
|
|
9960
9962
|
const PortalTemplates_stories = {
|
|
9961
9963
|
title: "Templates / Microsite",
|
|
@@ -20,6 +20,6 @@ export function LinkButtonView(props) {
|
|
|
20
20
|
h("style", { type: "text/css" },
|
|
21
21
|
styleString,
|
|
22
22
|
vanillaStyle),
|
|
23
|
-
h("sl-button", { type: "primary", exportparts: "base: primarybutton-base" },
|
|
24
|
-
h("a", {
|
|
23
|
+
h("sl-button", { onClick: onClick, type: "primary", exportparts: "base: primarybutton-base" },
|
|
24
|
+
h("a", { class: sheet.classes.Link, part: "sqm-link" }, buttonText))));
|
|
25
25
|
}
|
|
@@ -12,6 +12,7 @@ const errorProps = {
|
|
|
12
12
|
error: "Something went wrong. Please try again.",
|
|
13
13
|
loading: false,
|
|
14
14
|
verified: false,
|
|
15
|
+
success: false,
|
|
15
16
|
},
|
|
16
17
|
data: {
|
|
17
18
|
oobCode: "abc123",
|
|
@@ -31,6 +32,7 @@ const verifiedProps = {
|
|
|
31
32
|
error: "",
|
|
32
33
|
loading: false,
|
|
33
34
|
verified: true,
|
|
35
|
+
success: true,
|
|
34
36
|
},
|
|
35
37
|
data: {
|
|
36
38
|
oobCode: "abc123",
|
|
@@ -21,7 +21,9 @@ const sheet = createStyleSheet(style);
|
|
|
21
21
|
const styleString = sheet.toString();
|
|
22
22
|
export function PortalVerifyEmailView(props) {
|
|
23
23
|
const { states, data, callbacks, content } = props;
|
|
24
|
-
if (states.
|
|
24
|
+
if (states.loading)
|
|
25
|
+
return;
|
|
26
|
+
if (states.success) {
|
|
25
27
|
return (h("div", { class: sheet.classes.Wrapper, part: "sqm-base" },
|
|
26
28
|
h("style", { type: "text/css" },
|
|
27
29
|
vanillaStyle,
|
|
@@ -228,7 +228,7 @@ export class PortalVerifyEmail {
|
|
|
228
228
|
"mutable": false,
|
|
229
229
|
"complexType": {
|
|
230
230
|
"original": "DemoData<PortalVerifyEmailViewProps>",
|
|
231
|
-
"resolved": "{ states?: { error: string; loading: boolean; verified: boolean; }; data?: { oobCode: string; }; content?: { verifySuccessText?: string; verifyEmailText?: string; verifyInvalidText?: string; continueText?: string; }; }",
|
|
231
|
+
"resolved": "{ states?: { error: string; loading: boolean; success: boolean; verified: boolean; }; data?: { oobCode: string; }; content?: { verifySuccessText?: string; verifyEmailText?: string; verifyInvalidText?: string; continueText?: string; }; }",
|
|
232
232
|
"references": {
|
|
233
233
|
"DemoData": {
|
|
234
234
|
"location": "import",
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { navigation, setUserIdentity,
|
|
2
|
-
import { useEffect } from "@saasquatch/universal-hooks";
|
|
1
|
+
import { navigation, setUserIdentity, useVerifyEmailMutation, } from "@saasquatch/component-boilerplate";
|
|
2
|
+
import { useEffect, useState } from "@saasquatch/universal-hooks";
|
|
3
3
|
import { sanitizeUrlPath } from "../../utils/utils";
|
|
4
4
|
const SUBMITTED_CONTEXT = "sq:verify-submitted";
|
|
5
5
|
function setSubmitted(submitted) {
|
|
@@ -7,18 +7,31 @@ function setSubmitted(submitted) {
|
|
|
7
7
|
window[SUBMITTED_CONTEXT] = submitted;
|
|
8
8
|
}
|
|
9
9
|
export function usePortalVerifyEmail({ nextPage, failedPage, verifySuccessText, verifyEmailText, verifyInvalidText, networkErrorMessage, continueText, }) {
|
|
10
|
-
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
10
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
11
11
|
const submitted = window[SUBMITTED_CONTEXT];
|
|
12
|
-
const userIdent = useUserIdentity();
|
|
12
|
+
// const userIdent = useUserIdentity();
|
|
13
|
+
const [verificationError, setVerificationError] = useState(null);
|
|
14
|
+
const [success, setSuccess] = useState(false);
|
|
13
15
|
const [request, { loading, data, errors }] = useVerifyEmailMutation();
|
|
14
16
|
const urlParams = new URLSearchParams(navigation.location.search);
|
|
15
17
|
const oobCode = urlParams.get("oobCode");
|
|
18
|
+
const oobEmail = urlParams.get("email");
|
|
16
19
|
const nextPageOverride = urlParams.get("nextPage");
|
|
17
20
|
// derived from useMutation in component boilerplate initialState
|
|
18
21
|
const disableContinue = data === undefined && errors === undefined && !!oobCode;
|
|
19
22
|
// if logged out, userIdent?.managedIdentity?.emailVerified will be falsey, even if verification was successful
|
|
20
|
-
const
|
|
21
|
-
|
|
23
|
+
const userIdentContext = localStorage.getItem("sq:user-identity");
|
|
24
|
+
const userIdent = getUserIdent(userIdentContext);
|
|
25
|
+
const email = (_a = userIdent === null || userIdent === void 0 ? void 0 : userIdent.managedIdentity) === null || _a === void 0 ? void 0 : _a.email;
|
|
26
|
+
const verified = !!(((_b = userIdent === null || userIdent === void 0 ? void 0 : userIdent.managedIdentity) === null || _b === void 0 ? void 0 : _b.emailVerified) || (data === null || data === void 0 ? void 0 : data.verifyManagedIdentityEmail.success));
|
|
27
|
+
function getUserIdent(context) {
|
|
28
|
+
try {
|
|
29
|
+
return JSON.parse(context);
|
|
30
|
+
}
|
|
31
|
+
catch {
|
|
32
|
+
return undefined;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
22
35
|
const failed = () => {
|
|
23
36
|
return navigation.push({
|
|
24
37
|
pathname: failedPage,
|
|
@@ -30,47 +43,78 @@ export function usePortalVerifyEmail({ nextPage, failedPage, verifySuccessText,
|
|
|
30
43
|
const url = sanitizeUrlPath(nextPageOverride || nextPage);
|
|
31
44
|
navigation.push(url.href);
|
|
32
45
|
};
|
|
46
|
+
const logout = () => {
|
|
47
|
+
console.debug("LOGOUT");
|
|
48
|
+
setTimeout(() => {
|
|
49
|
+
gotoNextPage();
|
|
50
|
+
setUserIdentity(undefined);
|
|
51
|
+
setSubmitted(false);
|
|
52
|
+
}, 3000);
|
|
53
|
+
};
|
|
33
54
|
const submit = async () => {
|
|
34
|
-
var _a;
|
|
55
|
+
var _a, _b;
|
|
35
56
|
setSubmitted(true);
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
57
|
+
const response = await request({ oobCode });
|
|
58
|
+
if (response instanceof Error ||
|
|
59
|
+
!((_a = response === null || response === void 0 ? void 0 : response.verifyManagedIdentityEmail) === null || _a === void 0 ? void 0 : _a.success)) {
|
|
60
|
+
setVerificationError({ message: true });
|
|
61
|
+
}
|
|
62
|
+
else if ((_b = response === null || response === void 0 ? void 0 : response.verifyManagedIdentityEmail) === null || _b === void 0 ? void 0 : _b.success) {
|
|
63
|
+
setSuccess(true);
|
|
64
|
+
}
|
|
65
|
+
if (email && email !== oobEmail) {
|
|
66
|
+
console.debug("email mismatch", { response });
|
|
67
|
+
logout();
|
|
68
|
+
return;
|
|
48
69
|
}
|
|
70
|
+
console.debug("SUBMITTED", response);
|
|
49
71
|
};
|
|
50
72
|
useEffect(() => {
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
if (verified && !((_a = userIdent === null || userIdent === void 0 ? void 0 : userIdent.managedIdentity) === null || _a === void 0 ? void 0 : _a.emailVerified)) {
|
|
55
|
-
setUserIdentity(undefined);
|
|
56
|
-
gotoNextPage();
|
|
57
|
-
// Already verified, begin redirect
|
|
58
|
-
}
|
|
59
|
-
else if (verified) {
|
|
73
|
+
console.log({ verified, userIdent });
|
|
74
|
+
if (verified) {
|
|
75
|
+
setSuccess(true);
|
|
60
76
|
setTimeout(() => {
|
|
61
77
|
gotoNextPage();
|
|
78
|
+
setUserIdentity(undefined);
|
|
62
79
|
setSubmitted(false);
|
|
63
80
|
}, 3000);
|
|
64
|
-
return;
|
|
65
81
|
}
|
|
66
|
-
if (
|
|
82
|
+
else if (!data && !submitted && oobCode)
|
|
67
83
|
submit();
|
|
68
84
|
}, [verified, submitted, data, userIdent]);
|
|
85
|
+
// console.log({ hasContext, userIdent, data, submitted, verified, errors });
|
|
86
|
+
// useEffect(() => {
|
|
87
|
+
// if (errors && !verified) setVerificationError(errors);
|
|
88
|
+
// }, [errors, verified]);
|
|
89
|
+
// useEffect(() => {
|
|
90
|
+
// if (!data && !submitted && oobCode) submit();
|
|
91
|
+
// // verification successful but user in context is not verified
|
|
92
|
+
// // or mismatch between logged in user and user associated with oobCode
|
|
93
|
+
// if (submitted) {
|
|
94
|
+
// console.debug("in submit condition");
|
|
95
|
+
// if (email && email !== oobEmail) {
|
|
96
|
+
// console.debug("email mismatch");
|
|
97
|
+
// logout();
|
|
98
|
+
// return;
|
|
99
|
+
// // Already verified, begin redirect
|
|
100
|
+
// }
|
|
101
|
+
// if (verified) {
|
|
102
|
+
// if (!verificationError) setSuccess(true);
|
|
103
|
+
// console.debug("verified");
|
|
104
|
+
// setTimeout(() => {
|
|
105
|
+
// gotoNextPage();
|
|
106
|
+
// setSubmitted(false);
|
|
107
|
+
// }, 3000);
|
|
108
|
+
// return;
|
|
109
|
+
// }
|
|
110
|
+
// }
|
|
111
|
+
// }, [submitted, verificationError, data, email, oobCode, oobEmail, submit]);
|
|
69
112
|
return {
|
|
70
113
|
states: {
|
|
71
114
|
loading: loading || disableContinue,
|
|
72
|
-
|
|
73
|
-
|
|
115
|
+
success,
|
|
116
|
+
error: ((_f = (_e = (_d = (_c = verificationError === null || verificationError === void 0 ? void 0 : verificationError.response) === null || _c === void 0 ? void 0 : _c.errors) === null || _d === void 0 ? void 0 : _d[0]) === null || _e === void 0 ? void 0 : _e.extensions) === null || _f === void 0 ? void 0 : _f.message) || ((_j = (_h = (_g = verificationError === null || verificationError === void 0 ? void 0 : verificationError.response) === null || _g === void 0 ? void 0 : _g.errors) === null || _h === void 0 ? void 0 : _h[0]) === null || _j === void 0 ? void 0 : _j.message) ||
|
|
117
|
+
((verificationError === null || verificationError === void 0 ? void 0 : verificationError.message) && networkErrorMessage),
|
|
74
118
|
verified,
|
|
75
119
|
},
|
|
76
120
|
data: {
|
|
@@ -1504,8 +1504,8 @@ function LinkButtonView(props) {
|
|
|
1504
1504
|
h$1("style", { type: "text/css" },
|
|
1505
1505
|
styleString$1,
|
|
1506
1506
|
vanillaStyle),
|
|
1507
|
-
h$1("sl-button", { type: "primary", exportparts: "base: primarybutton-base" },
|
|
1508
|
-
h$1("a", {
|
|
1507
|
+
h$1("sl-button", { onClick: onClick, type: "primary", exportparts: "base: primarybutton-base" },
|
|
1508
|
+
h$1("a", { class: sheet$1.classes.Link, part: "sqm-link" }, buttonText))));
|
|
1509
1509
|
}
|
|
1510
1510
|
|
|
1511
1511
|
const LinkButton = class {
|
|
@@ -22,7 +22,9 @@ const sheet = createStyleSheet(style);
|
|
|
22
22
|
const styleString = sheet.toString();
|
|
23
23
|
function PortalVerifyEmailView(props) {
|
|
24
24
|
const { states, data, callbacks, content } = props;
|
|
25
|
-
if (states.
|
|
25
|
+
if (states.loading)
|
|
26
|
+
return;
|
|
27
|
+
if (states.success) {
|
|
26
28
|
return (h("div", { class: sheet.classes.Wrapper, part: "sqm-base" },
|
|
27
29
|
h("style", { type: "text/css" },
|
|
28
30
|
vanillaStyle,
|