@stokr/components-library 3.0.48 → 3.0.49

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.
@@ -9,10 +9,11 @@ import stdin_default$5 from "./EnterCode.js";
9
9
  import { AuthContext } from "../../context/AuthContext.js";
10
10
  import stdin_default$1 from "./Sucess2FA.js";
11
11
  import fetchData from "../../api/fetchData.js";
12
+ import { getFirebaseAuth } from "../../firebase-config.js";
12
13
  import { ModalInner, ModalBack } from "../Modal/Modal.styles.js";
13
14
  const stepsNames = ["app", "connect", "enter-code"];
14
15
  const Enable2FAFlow = ({ showFlow, setShowFlow, onSuccess, totpData, onRequiresRecentLoginError }) => {
15
- const { user, enrollUserToTotp, refreshIdToken } = useContext(AuthContext);
16
+ const { user, firebaseUser, enrollUserToTotp, refreshIdToken } = useContext(AuthContext);
16
17
  const [showSuccess, setshowSuccess] = useState(false);
17
18
  const [popupError, setpopupError] = useState({
18
19
  popup: void 0,
@@ -31,9 +32,17 @@ const Enable2FAFlow = ({ showFlow, setShowFlow, onSuccess, totpData, onRequiresR
31
32
  }
32
33
  }, [user]);
33
34
  const onSubmit = async (data) => {
34
- if (!user || !data) return console.log("not enough data");
35
+ if (!data) return console.log("not enough data");
36
+ const mfaUser = firebaseUser || getFirebaseAuth()?.currentUser || user;
37
+ if (!mfaUser) {
38
+ setpopupError({
39
+ popup: "enter2fa",
40
+ message: "Unable to complete 2FA setup. Please log in again and retry."
41
+ });
42
+ return;
43
+ }
35
44
  try {
36
- await enrollUserToTotp(user, totpData.totpSecret, data.otpInput, user.displayName);
45
+ await enrollUserToTotp(mfaUser, totpData.totpSecret, data.otpInput, user?.displayName || mfaUser?.displayName);
37
46
  setshowSuccess(true);
38
47
  try {
39
48
  await fetchData("auth/enable-2fa-email");
@@ -102,7 +102,9 @@ const LoginWithOTP = ({ withBackground, useRelativePathForMenu = false }) => {
102
102
  ...prev,
103
103
  login: false
104
104
  }));
105
- await showAccountLockedModal();
105
+ await showAccountLockedModal({
106
+ background: withBackground ? backgroundProp : void 0
107
+ });
106
108
  setIsModalOpen((prev) => ({
107
109
  ...prev,
108
110
  login: true
@@ -89,7 +89,7 @@ const Main2FAFlow = ({
89
89
  subtitle: /* @__PURE__ */ jsxs(Fragment, { children: [
90
90
  "Under our security policy, two-factor authentication is required on all accounts and cannot be turned off. To reset your method, contact our",
91
91
  " ",
92
- /* @__PURE__ */ jsx("a", { href: SUPPORT_URL, target: "_blank", rel: "noreferrer", children: "support team" }),
92
+ /* @__PURE__ */ jsx("a", { href: SUPPORT_URL, target: "_blank", rel: "noreferrer", style: { textDecoration: "underline" }, children: /* @__PURE__ */ jsx("u", { children: "support team" }) }),
93
93
  "."
94
94
  ] }),
95
95
  maxWidth: "820px"
@@ -4,15 +4,18 @@ import { showProgress } from "../components/Modal/SuccessModal/SuccessModal.js";
4
4
  const SUPPORT_URL = "https://support.stokr.io/";
5
5
  const ACCOUNT_LOCKED_CODE = "auth/user-disabled";
6
6
  const isAccountLockedError = (error) => error?.code === ACCOUNT_LOCKED_CODE;
7
- const showAccountLockedModal = () => showProgress({
7
+ const showAccountLockedModal = ({ background } = {}) => showProgress({
8
8
  title: "TOO MANY ATTEMPTS",
9
9
  subtitle: /* @__PURE__ */ jsxs(Fragment, { children: [
10
10
  "For your security, your account has been temporarily locked after multiple failed sign-in attempts. To restore access, contact our",
11
11
  " ",
12
- /* @__PURE__ */ jsx("a", { href: SUPPORT_URL, target: "_blank", rel: "noreferrer", children: "support team" }),
12
+ /* @__PURE__ */ jsx("a", { href: SUPPORT_URL, target: "_blank", rel: "noreferrer", style: { textDecoration: "underline" }, children: /* @__PURE__ */ jsx("u", { children: "support team" }) }),
13
13
  "."
14
14
  ] }),
15
- maxWidth: "820px"
15
+ maxWidth: "820px",
16
+ modalProps: {
17
+ background
18
+ }
16
19
  });
17
20
  export {
18
21
  isAccountLockedError,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stokr/components-library",
3
- "version": "3.0.48",
3
+ "version": "3.0.49",
4
4
  "description": "STOKR - Components Library",
5
5
  "author": "Bilal Hodzic <bilal@stokr.io>",
6
6
  "license": "MIT",