@logora/debate 0.4.110 → 0.4.111
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/assets/components/auth/subscription_modal/SubscriptionModal.module-xQS4aWtJ.css +1 -0
- package/dist/components/auth/auth_modal/AuthModal.js +38 -29
- package/dist/components/auth/sso_form/SSOForm.js +36 -33
- package/dist/components/auth/subscription_modal/SubscriptionModal.js +26 -0
- package/dist/components/auth/subscription_modal/SubscriptionModal.module.scss.js +9 -0
- package/dist/components/auth/subscription_modal/index.js +4 -0
- package/dist/components/hooks/use_auth_required/useAuthRequired.js +22 -10
- package/dist/components/input/argument_input/ArgumentInput.js +145 -145
- package/dist/components/vote/use_vote/useVote.js +20 -20
- package/dist/index.js +232 -228
- package/package.json +1 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
._body_14nv4_3{display:flex;flex-direction:column;align-items:center;text-align:center;gap:1em;padding-top:var(--spacer-xxs, calc(var(--space-unit, 1em) * .25))!important;padding-bottom:var(--spacer-xxs, calc(var(--space-unit, 1em) * .25))!important;padding-right:var(--spacer-xxs, calc(var(--space-unit, 1em) * .25))!important;padding-left:var(--spacer-xxs, calc(var(--space-unit, 1em) * .25))!important}._title_14nv4_15{font-weight:700;font-size:1.2em}
|
|
@@ -1,44 +1,50 @@
|
|
|
1
|
-
import { jsx as t, Fragment as
|
|
1
|
+
import { jsx as t, Fragment as C } from "react/jsx-runtime";
|
|
2
2
|
import { useState as h, useEffect as m } from "react";
|
|
3
|
-
import
|
|
4
|
-
import { useConfig as
|
|
5
|
-
import { useModal as
|
|
6
|
-
import { useAuth as
|
|
7
|
-
import { useAuthActions as
|
|
8
|
-
import { httpClient as
|
|
9
|
-
import { Modal as
|
|
10
|
-
import { Loader as
|
|
11
|
-
import { SocialAuthForm as
|
|
12
|
-
import { SSOForm as
|
|
13
|
-
import { AuthProviderFactory as
|
|
14
|
-
const
|
|
15
|
-
|
|
16
|
-
|
|
3
|
+
import E from "./AuthModal.module.scss.js";
|
|
4
|
+
import { useConfig as P } from "../../data/config_provider/useConfig.js";
|
|
5
|
+
import { useModal as T } from "../../dialog/modal/useModal.js";
|
|
6
|
+
import { useAuth as L } from "../use_auth/useAuth.js";
|
|
7
|
+
import { useAuthActions as R } from "../use_auth/useAuthActions.js";
|
|
8
|
+
import { httpClient as B } from "../../data/http_client/httpClient.js";
|
|
9
|
+
import { Modal as M } from "../../dialog/modal/Modal.js";
|
|
10
|
+
import { Loader as O } from "../../progress/loader/Loader.js";
|
|
11
|
+
import { SocialAuthForm as b } from "../social_auth_form/SocialAuthForm.js";
|
|
12
|
+
import { SSOForm as N } from "../sso_form/SSOForm.js";
|
|
13
|
+
import { AuthProviderFactory as S } from "../providers/AuthProviderFactory.js";
|
|
14
|
+
const V = ({
|
|
15
|
+
onHideModal: s = null,
|
|
16
|
+
title: c,
|
|
17
|
+
text: p,
|
|
18
|
+
buttonLabel: d,
|
|
19
|
+
url: g
|
|
20
|
+
}) => {
|
|
21
|
+
const o = P(), { hideModal: f } = T(), { isLoggedIn: l, authError: r } = L(), [A, n] = h(!1), [e, U] = h(null), { loginUser: v } = R(
|
|
22
|
+
B,
|
|
17
23
|
process.env.API_AUTH_URL,
|
|
18
24
|
"logora_user_token"
|
|
19
25
|
);
|
|
20
26
|
m(() => {
|
|
21
|
-
l &&
|
|
27
|
+
l && _();
|
|
22
28
|
}, [l]), m(() => {
|
|
23
29
|
e && r && n(!1);
|
|
24
30
|
}, [e, r]);
|
|
25
|
-
const
|
|
26
|
-
|
|
27
|
-
},
|
|
28
|
-
|
|
29
|
-
},
|
|
30
|
-
const
|
|
31
|
+
const _ = () => {
|
|
32
|
+
f(), s && s();
|
|
33
|
+
}, w = (i, a, u) => {
|
|
34
|
+
U(u), n(!0), I(i, a);
|
|
35
|
+
}, I = (i, a) => {
|
|
36
|
+
const y = S.create(
|
|
31
37
|
o.auth?.type,
|
|
32
38
|
o.shortname,
|
|
33
39
|
i,
|
|
34
40
|
a
|
|
35
41
|
).getAuthorizationParams();
|
|
36
|
-
|
|
42
|
+
v(y);
|
|
37
43
|
};
|
|
38
|
-
return /* @__PURE__ */ t(
|
|
39
|
-
|
|
44
|
+
return /* @__PURE__ */ t(M, { "data-vid": "login_modal", children: /* @__PURE__ */ t("div", { className: E.loginModalBody, children: A ? /* @__PURE__ */ t(O, {}) : /* @__PURE__ */ t(C, { children: o.auth.type === "form" || o.auth.type === "social" ? /* @__PURE__ */ t(
|
|
45
|
+
b,
|
|
40
46
|
{
|
|
41
|
-
onSubmit:
|
|
47
|
+
onSubmit: w,
|
|
42
48
|
error: r,
|
|
43
49
|
lastStep: e,
|
|
44
50
|
facebookClientId: process.env.FACEBOOK_CLIENT_ID,
|
|
@@ -51,7 +57,7 @@ const $ = ({ onHideModal: s = null }) => {
|
|
|
51
57
|
privacyUrl: o.provider?.privacyUrl || "https://www.logora.com/blog-posts/privacy-policy"
|
|
52
58
|
}
|
|
53
59
|
) : /* @__PURE__ */ t(
|
|
54
|
-
|
|
60
|
+
N,
|
|
55
61
|
{
|
|
56
62
|
authType: o.auth.type,
|
|
57
63
|
error: r && e === "OAUTH2",
|
|
@@ -60,7 +66,10 @@ const $ = ({ onHideModal: s = null }) => {
|
|
|
60
66
|
scope: o.auth.scope,
|
|
61
67
|
logoUrl: o.logo_url,
|
|
62
68
|
loginUrl: o.auth.login_url,
|
|
63
|
-
signupUrl: o.auth.registration_url || o.auth.login_url,
|
|
69
|
+
signupUrl: g || o.auth.registration_url || o.auth.login_url,
|
|
70
|
+
title: c,
|
|
71
|
+
subtitle: p,
|
|
72
|
+
signupLabel: d,
|
|
64
73
|
termsUrl: o.provider?.cguUrl || "https://www.logora.com/blog-posts/cgu",
|
|
65
74
|
redirectParameter: o.auth.redirectParameter,
|
|
66
75
|
trackingParameters: o.auth.trackingParameters,
|
|
@@ -74,5 +83,5 @@ const $ = ({ onHideModal: s = null }) => {
|
|
|
74
83
|
) }) }) });
|
|
75
84
|
};
|
|
76
85
|
export {
|
|
77
|
-
|
|
86
|
+
V as AuthModal
|
|
78
87
|
};
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import { jsxs as n, jsx as e, Fragment as m } from "react/jsx-runtime";
|
|
2
|
-
import
|
|
2
|
+
import z from "classnames";
|
|
3
3
|
import "react";
|
|
4
|
-
import { useIntl as
|
|
5
|
-
import { useLocation as
|
|
4
|
+
import { useIntl as H, FormattedMessage as w } from "react-intl";
|
|
5
|
+
import { useLocation as K } from "react-router";
|
|
6
6
|
import a from "./SSOForm.module.scss.js";
|
|
7
|
-
import { useSessionStorageState as
|
|
8
|
-
import { Icon as
|
|
9
|
-
import { Button as
|
|
10
|
-
import { Toggle as
|
|
11
|
-
import { EMAIL_CONSENT_STORAGE_KEY as
|
|
12
|
-
import { utf8ToBase64url as
|
|
13
|
-
const
|
|
7
|
+
import { useSessionStorageState as V } from "../../hooks/use_session_storage_state/useSessionStorageState.js";
|
|
8
|
+
import { Icon as W } from "../../icons/icon/Icon.js";
|
|
9
|
+
import { Button as $ } from "../../action/button/Button.js";
|
|
10
|
+
import { Toggle as q } from "../../input/toggle/Toggle.js";
|
|
11
|
+
import { EMAIL_CONSENT_STORAGE_KEY as J } from "../use_auth/useAuthActions.js";
|
|
12
|
+
import { utf8ToBase64url as Q } from "../use_auth/base64.js";
|
|
13
|
+
const de = ({
|
|
14
14
|
authType: v,
|
|
15
15
|
providerName: c,
|
|
16
16
|
loginUrl: M,
|
|
@@ -27,41 +27,44 @@ const ie = ({
|
|
|
27
27
|
showEmailConsent: g = !1,
|
|
28
28
|
showTerms: L = !1,
|
|
29
29
|
hideBelowButton: x = !1,
|
|
30
|
-
error: R = !1
|
|
30
|
+
error: R = !1,
|
|
31
|
+
title: T,
|
|
32
|
+
subtitle: A,
|
|
33
|
+
signupLabel: C
|
|
31
34
|
}) => {
|
|
32
|
-
const [h,
|
|
33
|
-
}], o =
|
|
35
|
+
const [h, B] = g ? V(J, !1) : [!1, () => {
|
|
36
|
+
}], o = H(), d = K(), O = (t) => {
|
|
34
37
|
if (typeof window < "u") {
|
|
35
|
-
const s = t === "CURRENT_LOCATION" ? window.location : t, i = new URL(s, window.location.origin), l = i.searchParams,
|
|
38
|
+
const s = t === "CURRENT_LOCATION" ? window.location : t, i = new URL(s, window.location.origin), l = i.searchParams, G = new URLSearchParams(d.search);
|
|
36
39
|
l.has("code") && l.delete("code"), f && l.append(f, window.location.toString());
|
|
37
|
-
for (const [_,
|
|
38
|
-
let r =
|
|
40
|
+
for (const [_, D] of Object.entries(P)) {
|
|
41
|
+
let r = D;
|
|
39
42
|
if (r) {
|
|
40
|
-
const
|
|
43
|
+
const Y = d.pathname.slice(
|
|
41
44
|
0,
|
|
42
45
|
d.pathname.lastIndexOf("/")
|
|
43
46
|
);
|
|
44
47
|
r = r.replace(
|
|
45
48
|
"{{UTM_CAMPAIGN}}",
|
|
46
|
-
|
|
49
|
+
G.get("utm_campaign")
|
|
47
50
|
), r = r.replace(
|
|
48
51
|
"{{CURRENT_PATH}}",
|
|
49
|
-
decodeURIComponent(
|
|
52
|
+
decodeURIComponent(Y)
|
|
50
53
|
);
|
|
51
54
|
}
|
|
52
|
-
_ === "metadata" && r && (r =
|
|
55
|
+
_ === "metadata" && r && (r = Q(r)), l.append(_, r);
|
|
53
56
|
}
|
|
54
57
|
return i.search = l.toString(), i.toString();
|
|
55
58
|
}
|
|
56
59
|
return "";
|
|
57
|
-
},
|
|
60
|
+
}, E = (t) => {
|
|
58
61
|
const s = new URL(t);
|
|
59
62
|
if (s.searchParams.delete("code"), s.searchParams.append("client_id", S), s.searchParams.append("redirect_uri", y), s.searchParams.append("scope", I), s.searchParams.append("response_type", "code"), typeof window < "u") {
|
|
60
63
|
const i = new URL(window.location.href);
|
|
61
64
|
i.searchParams.delete("code"), s.searchParams.append("state", window.btoa(i.toString()));
|
|
62
65
|
}
|
|
63
66
|
return s.href;
|
|
64
|
-
}, p = (t) => v === "oauth2_server" ?
|
|
67
|
+
}, p = (t) => v === "oauth2_server" ? E(t) : O(t), F = p(M), j = p(b);
|
|
65
68
|
return /* @__PURE__ */ n("div", { className: a.ssoForm, children: [
|
|
66
69
|
/* @__PURE__ */ e("div", { className: a.logo, children: u ? /* @__PURE__ */ e(
|
|
67
70
|
"img",
|
|
@@ -73,7 +76,7 @@ const ie = ({
|
|
|
73
76
|
alt: `Logo ${c}`
|
|
74
77
|
}
|
|
75
78
|
) : /* @__PURE__ */ e(
|
|
76
|
-
|
|
79
|
+
W,
|
|
77
80
|
{
|
|
78
81
|
name: "next",
|
|
79
82
|
"aria-hidden": "true",
|
|
@@ -84,13 +87,13 @@ const ie = ({
|
|
|
84
87
|
) }),
|
|
85
88
|
/* @__PURE__ */ n("div", { className: a.mainText, children: [
|
|
86
89
|
/* @__PURE__ */ n("div", { className: a.title, children: [
|
|
87
|
-
o.formatMessage({
|
|
90
|
+
T || o.formatMessage({
|
|
88
91
|
id: "auth.sso_form.title",
|
|
89
92
|
defaultMessage: "Debate now !"
|
|
90
93
|
}),
|
|
91
94
|
/* @__PURE__ */ e("br", {})
|
|
92
95
|
] }),
|
|
93
|
-
o.formatMessage(
|
|
96
|
+
A || o.formatMessage(
|
|
94
97
|
{
|
|
95
98
|
id: "auth.sso_form.subtitle",
|
|
96
99
|
defaultMessage: "Sign up right now and receive alerts by email."
|
|
@@ -100,15 +103,15 @@ const ie = ({
|
|
|
100
103
|
] }),
|
|
101
104
|
U ? null : /* @__PURE__ */ n(m, { children: [
|
|
102
105
|
/* @__PURE__ */ e(
|
|
103
|
-
|
|
106
|
+
$,
|
|
104
107
|
{
|
|
105
108
|
"data-tid": "link_signup",
|
|
106
109
|
"data-testid": "signup-button",
|
|
107
110
|
className: a.loginButton,
|
|
108
|
-
to:
|
|
111
|
+
to: j,
|
|
109
112
|
external: !0,
|
|
110
113
|
border: !1,
|
|
111
|
-
children: o.formatMessage({
|
|
114
|
+
children: C || o.formatMessage({
|
|
112
115
|
id: "auth.sso_form.signup",
|
|
113
116
|
defaultMessage: "Sign up"
|
|
114
117
|
})
|
|
@@ -127,7 +130,7 @@ const ie = ({
|
|
|
127
130
|
"data-testid": "signin-link",
|
|
128
131
|
"data-tid": "link_login",
|
|
129
132
|
rel: "nofollow",
|
|
130
|
-
href:
|
|
133
|
+
href: F,
|
|
131
134
|
children: o.formatMessage({
|
|
132
135
|
id: "auth.sso_form.signin",
|
|
133
136
|
defaultMessage: "Sign in"
|
|
@@ -135,8 +138,8 @@ const ie = ({
|
|
|
135
138
|
}
|
|
136
139
|
)
|
|
137
140
|
] }),
|
|
138
|
-
g ? /* @__PURE__ */ e("div", { className:
|
|
139
|
-
|
|
141
|
+
g ? /* @__PURE__ */ e("div", { className: z(a.switchBox), children: /* @__PURE__ */ e(
|
|
142
|
+
q,
|
|
140
143
|
{
|
|
141
144
|
type: "checkbox",
|
|
142
145
|
name: "accepts_provider_email",
|
|
@@ -149,7 +152,7 @@ const ie = ({
|
|
|
149
152
|
},
|
|
150
153
|
{ variable: c }
|
|
151
154
|
),
|
|
152
|
-
onInputChanged: (t) =>
|
|
155
|
+
onInputChanged: (t) => B(!h),
|
|
153
156
|
"data-testid": "accepts-email-input"
|
|
154
157
|
}
|
|
155
158
|
) }) : null,
|
|
@@ -190,5 +193,5 @@ const ie = ({
|
|
|
190
193
|
] });
|
|
191
194
|
};
|
|
192
195
|
export {
|
|
193
|
-
|
|
196
|
+
de as SSOForm
|
|
194
197
|
};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { jsx as t, jsxs as d } from "react/jsx-runtime";
|
|
2
|
+
import "react";
|
|
3
|
+
import { useIntl as l } from "react-intl";
|
|
4
|
+
import o from "./SubscriptionModal.module.scss.js";
|
|
5
|
+
import { Modal as m } from "../../dialog/modal/Modal.js";
|
|
6
|
+
import { Button as n } from "../../action/button/Button.js";
|
|
7
|
+
const M = ({ title: i, text: r, buttonLabel: a, url: s }) => {
|
|
8
|
+
const e = l();
|
|
9
|
+
return /* @__PURE__ */ t(m, { "data-vid": "subscription_modal", showCloseButton: !0, children: /* @__PURE__ */ d("div", { className: o.body, children: [
|
|
10
|
+
/* @__PURE__ */ t("div", { className: o.title, children: i || e.formatMessage({
|
|
11
|
+
id: "auth.subscription_modal.title",
|
|
12
|
+
defaultMessage: "Subscribe to comment"
|
|
13
|
+
}) }),
|
|
14
|
+
/* @__PURE__ */ t("div", { children: r || e.formatMessage({
|
|
15
|
+
id: "auth.subscription_modal.text",
|
|
16
|
+
defaultMessage: "Commenting is reserved to subscribers."
|
|
17
|
+
}) }),
|
|
18
|
+
s && /* @__PURE__ */ t(n, { "data-tid": "link_subscribe", to: s, external: !0, border: !1, children: a || e.formatMessage({
|
|
19
|
+
id: "auth.subscription_modal.button",
|
|
20
|
+
defaultMessage: "Subscribe"
|
|
21
|
+
}) })
|
|
22
|
+
] }) });
|
|
23
|
+
};
|
|
24
|
+
export {
|
|
25
|
+
M as SubscriptionModal
|
|
26
|
+
};
|
|
@@ -1,10 +1,20 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { useContext as i, Suspense as
|
|
3
|
-
import { ConfigContext as
|
|
4
|
-
import { useModal as
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
import { jsx as n } from "react/jsx-runtime";
|
|
2
|
+
import { createContext as f, useContext as i, Suspense as s, lazy as l } from "react";
|
|
3
|
+
import { ConfigContext as c } from "../../data/config_provider/ConfigProvider.js";
|
|
4
|
+
import { useModal as h } from "../../dialog/modal/useModal.js";
|
|
5
|
+
import { useAuth as m } from "../../auth/use_auth/useAuth.js";
|
|
6
|
+
const p = l(() => import("../../auth/auth_modal/index.js").then((t) => ({ default: t.AuthModal }))), w = l(() => import("../../auth/subscription_modal/index.js").then((t) => ({ default: t.SubscriptionModal }))), d = f(null), b = () => {
|
|
7
|
+
const { config: t } = i(c), o = i(d), { isLoggedIn: r, currentUser: e } = m() || {};
|
|
8
|
+
return !!(r && o && t?.[o]?.subscribersOnly === !0 && e?.is_subscriber !== !0);
|
|
9
|
+
}, R = () => {
|
|
10
|
+
const { config: t } = i(c), o = i(d), r = b(), { showModal: e } = h(), u = o ? t?.[o] : null;
|
|
11
|
+
return (a = {}) => {
|
|
12
|
+
if (r) {
|
|
13
|
+
e(
|
|
14
|
+
/* @__PURE__ */ n(s, { fallback: null, children: /* @__PURE__ */ n(w, { ...u?.subscriptionModal }) })
|
|
15
|
+
);
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
8
18
|
typeof window < "u" && (window.dispatchEvent(
|
|
9
19
|
new CustomEvent("LOGORA::authenticationRequired", {
|
|
10
20
|
detail: { redirectUrl: window.location.href }
|
|
@@ -13,11 +23,13 @@ const l = u(() => import("../../auth/auth_modal/index.js").then((t) => ({ defaul
|
|
|
13
23
|
new CustomEvent("logora:authentication:requested", {
|
|
14
24
|
detail: { redirectUrl: window.location.href }
|
|
15
25
|
})
|
|
16
|
-
)), t?.auth?.disableLoginModal !== !0 &&
|
|
17
|
-
/* @__PURE__ */
|
|
26
|
+
)), t?.auth?.disableLoginModal !== !0 && e(
|
|
27
|
+
/* @__PURE__ */ n(s, { fallback: null, children: /* @__PURE__ */ n(p, { ...u?.loginModal, ...a }) })
|
|
18
28
|
);
|
|
19
29
|
};
|
|
20
30
|
};
|
|
21
31
|
export {
|
|
22
|
-
|
|
32
|
+
d as ModuleContext,
|
|
33
|
+
R as useAuthRequired,
|
|
34
|
+
b as useSubscriptionRequired
|
|
23
35
|
};
|