@logora/debate 0.4.39 → 0.4.40
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.
|
@@ -5,15 +5,15 @@ import { useConfig as I } from "../../data/config_provider/useConfig.js";
|
|
|
5
5
|
import { useModal as y } from "../../dialog/modal/useModal.js";
|
|
6
6
|
import { useAuth as C } from "../use_auth/useAuth.js";
|
|
7
7
|
import { useAuthActions as E } from "../use_auth/useAuthActions.js";
|
|
8
|
-
import { httpClient as
|
|
9
|
-
import { Modal as
|
|
8
|
+
import { httpClient as T } from "../../data/axios_client/httpClient.js";
|
|
9
|
+
import { Modal as P } from "../../dialog/modal/Modal.js";
|
|
10
10
|
import { Loader as R } from "../../progress/loader/Loader.js";
|
|
11
11
|
import { SocialAuthForm as B } from "../social_auth_form/SocialAuthForm.js";
|
|
12
12
|
import { SSOForm as L } from "../sso_form/SSOForm.js";
|
|
13
13
|
import { AuthProviderFactory as M } from "../providers/AuthProviderFactory.js";
|
|
14
14
|
const $ = ({ onHideModal: s = null }) => {
|
|
15
15
|
const o = I(), { hideModal: c } = y(), { isLoggedIn: l, authError: r } = C(), [p, n] = h(!1), [e, d] = h(null), { loginUser: g } = E(
|
|
16
|
-
|
|
16
|
+
T,
|
|
17
17
|
process.env.API_AUTH_URL,
|
|
18
18
|
"logora_user_token"
|
|
19
19
|
);
|
|
@@ -35,7 +35,7 @@ const $ = ({ onHideModal: s = null }) => {
|
|
|
35
35
|
).getAuthorizationParams();
|
|
36
36
|
g(v);
|
|
37
37
|
};
|
|
38
|
-
return /* @__PURE__ */ t(
|
|
38
|
+
return /* @__PURE__ */ t(P, { "data-vid": "login_modal", children: /* @__PURE__ */ t("div", { className: w.loginModalBody, children: p ? /* @__PURE__ */ t(R, {}) : /* @__PURE__ */ t(_, { children: o.auth.type === "form" || o.auth.type === "social" ? /* @__PURE__ */ t(
|
|
39
39
|
B,
|
|
40
40
|
{
|
|
41
41
|
onSubmit: A,
|
|
@@ -69,7 +69,8 @@ const $ = ({ onHideModal: s = null }) => {
|
|
|
69
69
|
hideLoginButton: o.auth.hideModalLoginButton,
|
|
70
70
|
showEmailConsent: o.auth.showEmailConsent,
|
|
71
71
|
showTerms: o.auth.hideCgu !== !0,
|
|
72
|
-
hideBelowButton: o.auth.hideBelowButton
|
|
72
|
+
hideBelowButton: o.auth.hideBelowButton,
|
|
73
|
+
hideTerms: o.auth.hideTerms
|
|
73
74
|
}
|
|
74
75
|
) }) }) });
|
|
75
76
|
};
|
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import
|
|
3
|
-
import
|
|
1
|
+
import { jsxs as o, jsx as e, Fragment as d } from "react/jsx-runtime";
|
|
2
|
+
import D from "@rooks/use-sessionstorage-state";
|
|
3
|
+
import Y from "classnames";
|
|
4
4
|
import "react";
|
|
5
|
-
import { useIntl as
|
|
6
|
-
import { useLocation as
|
|
5
|
+
import { useIntl as z, FormattedMessage as w } from "react-intl";
|
|
6
|
+
import { useLocation as H } from "react-router";
|
|
7
7
|
import a from "./SSOForm.module.scss.js";
|
|
8
|
-
import { EMAIL_CONSENT_STORAGE_KEY as
|
|
9
|
-
import { Icon as
|
|
10
|
-
import { Button as
|
|
11
|
-
import { Toggle as
|
|
12
|
-
const
|
|
8
|
+
import { EMAIL_CONSENT_STORAGE_KEY as K } from "../use_auth/useAuthActions.js";
|
|
9
|
+
import { Icon as V } from "../../icons/icon/Icon.js";
|
|
10
|
+
import { Button as W } from "../../action/button/Button.js";
|
|
11
|
+
import { Toggle as $ } from "../../input/toggle/Toggle.js";
|
|
12
|
+
const ne = ({
|
|
13
13
|
authType: v,
|
|
14
|
-
providerName:
|
|
14
|
+
providerName: c,
|
|
15
15
|
loginUrl: M,
|
|
16
16
|
signupUrl: b,
|
|
17
17
|
termsUrl: N,
|
|
@@ -26,26 +26,27 @@ const oe = ({
|
|
|
26
26
|
showEmailConsent: g = !1,
|
|
27
27
|
showTerms: L = !1,
|
|
28
28
|
hideBelowButton: R = !1,
|
|
29
|
-
|
|
29
|
+
hideTerms: x = !1,
|
|
30
|
+
error: A = !1
|
|
30
31
|
}) => {
|
|
31
|
-
const [h,
|
|
32
|
-
}],
|
|
32
|
+
const [h, C] = g ? D(K, !1) : [!1, () => {
|
|
33
|
+
}], n = z(), m = H(), T = (t) => {
|
|
33
34
|
if (typeof window < "u") {
|
|
34
|
-
const s = t === "CURRENT_LOCATION" ? window.location : t, i = new URL(s, window.location.origin), l = i.searchParams,
|
|
35
|
+
const s = t === "CURRENT_LOCATION" ? window.location : t, i = new URL(s, window.location.origin), l = i.searchParams, F = new URLSearchParams(m.search);
|
|
35
36
|
l.has("code") && l.delete("code"), f && l.append(f, window.location.toString());
|
|
36
|
-
for (const [_,
|
|
37
|
-
let r =
|
|
37
|
+
for (const [_, j] of Object.entries(U)) {
|
|
38
|
+
let r = j;
|
|
38
39
|
if (r) {
|
|
39
|
-
const
|
|
40
|
+
const G = m.pathname.slice(
|
|
40
41
|
0,
|
|
41
|
-
|
|
42
|
+
m.pathname.lastIndexOf("/")
|
|
42
43
|
);
|
|
43
44
|
r = r.replace(
|
|
44
45
|
"{{UTM_CAMPAIGN}}",
|
|
45
|
-
|
|
46
|
+
F.get("utm_campaign")
|
|
46
47
|
), r = r.replace(
|
|
47
48
|
"{{CURRENT_PATH}}",
|
|
48
|
-
decodeURIComponent(
|
|
49
|
+
decodeURIComponent(G)
|
|
49
50
|
);
|
|
50
51
|
}
|
|
51
52
|
_ === "metadata" && r && (r = window.btoa(r)), l.append(_, encodeURIComponent(r));
|
|
@@ -53,15 +54,15 @@ const oe = ({
|
|
|
53
54
|
return i.search = l.toString(), i.toString();
|
|
54
55
|
}
|
|
55
56
|
return "";
|
|
56
|
-
},
|
|
57
|
+
}, O = (t) => {
|
|
57
58
|
const s = new URL(t);
|
|
58
59
|
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") {
|
|
59
60
|
const i = new URL(window.location.href);
|
|
60
61
|
i.searchParams.delete("code"), s.searchParams.append("state", window.btoa(i.toString()));
|
|
61
62
|
}
|
|
62
63
|
return s.href;
|
|
63
|
-
}, p = (t) => v === "oauth2_server" ?
|
|
64
|
-
return /* @__PURE__ */
|
|
64
|
+
}, p = (t) => v === "oauth2_server" ? O(t) : T(t), B = p(M), E = p(b);
|
|
65
|
+
return /* @__PURE__ */ o("div", { className: a.ssoForm, children: [
|
|
65
66
|
/* @__PURE__ */ e("div", { className: a.logo, children: u ? /* @__PURE__ */ e(
|
|
66
67
|
"img",
|
|
67
68
|
{
|
|
@@ -69,10 +70,10 @@ const oe = ({
|
|
|
69
70
|
width: 100,
|
|
70
71
|
className: a.logoImage,
|
|
71
72
|
src: u,
|
|
72
|
-
alt: `Logo ${
|
|
73
|
+
alt: `Logo ${c}`
|
|
73
74
|
}
|
|
74
75
|
) : /* @__PURE__ */ e(
|
|
75
|
-
|
|
76
|
+
V,
|
|
76
77
|
{
|
|
77
78
|
name: "next",
|
|
78
79
|
"aria-hidden": "true",
|
|
@@ -81,41 +82,41 @@ const oe = ({
|
|
|
81
82
|
className: a.loginIcon
|
|
82
83
|
}
|
|
83
84
|
) }),
|
|
84
|
-
/* @__PURE__ */
|
|
85
|
-
/* @__PURE__ */
|
|
86
|
-
|
|
85
|
+
/* @__PURE__ */ o("div", { className: a.mainText, children: [
|
|
86
|
+
/* @__PURE__ */ o("div", { className: a.title, children: [
|
|
87
|
+
n.formatMessage({
|
|
87
88
|
id: "auth.sso_form.title",
|
|
88
89
|
defaultMessage: "Debate now !"
|
|
89
90
|
}),
|
|
90
91
|
/* @__PURE__ */ e("br", {})
|
|
91
92
|
] }),
|
|
92
|
-
|
|
93
|
+
n.formatMessage(
|
|
93
94
|
{
|
|
94
95
|
id: "auth.sso_form.subtitle",
|
|
95
96
|
defaultMessage: "Sign up right now and receive alerts by email."
|
|
96
97
|
},
|
|
97
|
-
{ provider:
|
|
98
|
+
{ provider: c }
|
|
98
99
|
)
|
|
99
100
|
] }),
|
|
100
|
-
P ? null : /* @__PURE__ */
|
|
101
|
+
P ? null : /* @__PURE__ */ o(d, { children: [
|
|
101
102
|
/* @__PURE__ */ e(
|
|
102
|
-
|
|
103
|
+
W,
|
|
103
104
|
{
|
|
104
105
|
"data-tid": "link_signup",
|
|
105
106
|
"data-testid": "signup-button",
|
|
106
107
|
className: a.loginButton,
|
|
107
|
-
to:
|
|
108
|
+
to: E,
|
|
108
109
|
external: !0,
|
|
109
110
|
border: !1,
|
|
110
|
-
children:
|
|
111
|
+
children: n.formatMessage({
|
|
111
112
|
id: "auth.sso_form.signup",
|
|
112
113
|
defaultMessage: "Sign up"
|
|
113
114
|
})
|
|
114
115
|
}
|
|
115
116
|
),
|
|
116
|
-
R ? null : /* @__PURE__ */
|
|
117
|
-
k === !0 ? null : /* @__PURE__ */
|
|
118
|
-
|
|
117
|
+
R ? null : /* @__PURE__ */ o(d, { children: [
|
|
118
|
+
k === !0 ? null : /* @__PURE__ */ o("div", { className: a.cgu, children: [
|
|
119
|
+
n.formatMessage({
|
|
119
120
|
id: "auth.sso_form.already_account",
|
|
120
121
|
defaultMessage: "Already have an account ?"
|
|
121
122
|
}),
|
|
@@ -126,68 +127,70 @@ const oe = ({
|
|
|
126
127
|
"data-testid": "signin-link",
|
|
127
128
|
"data-tid": "link_login",
|
|
128
129
|
rel: "nofollow",
|
|
129
|
-
href:
|
|
130
|
-
children:
|
|
130
|
+
href: B,
|
|
131
|
+
children: n.formatMessage({
|
|
131
132
|
id: "auth.sso_form.signin",
|
|
132
133
|
defaultMessage: "Sign in"
|
|
133
134
|
})
|
|
134
135
|
}
|
|
135
136
|
)
|
|
136
137
|
] }),
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
type: "checkbox",
|
|
141
|
-
name: "accepts_provider_email",
|
|
142
|
-
style: { fontSize: 18 },
|
|
143
|
-
checked: h,
|
|
144
|
-
label: o.formatMessage(
|
|
145
|
-
{
|
|
146
|
-
id: "auth.sso_form.consent_label",
|
|
147
|
-
defaultMessage: "I agree to receive emails from the editor"
|
|
148
|
-
},
|
|
149
|
-
{ variable: d }
|
|
150
|
-
),
|
|
151
|
-
onInputChanged: (t) => A(!h),
|
|
152
|
-
"data-testid": "accepts-email-input"
|
|
153
|
-
}
|
|
154
|
-
) }) : null,
|
|
155
|
-
x ? /* @__PURE__ */ e("div", { className: a.error, children: o.formatMessage({
|
|
156
|
-
id: "auth.sso_form.error",
|
|
157
|
-
defaultMessage: "An error occurred during sign in. Please try again in a few moments."
|
|
158
|
-
}) }) : null,
|
|
159
|
-
L && /* @__PURE__ */ n(m, { children: [
|
|
160
|
-
/* @__PURE__ */ e("div", { className: a.cguButton, children: /* @__PURE__ */ e(
|
|
161
|
-
w,
|
|
162
|
-
{
|
|
163
|
-
id: "auth.sso_form.terms",
|
|
164
|
-
defaultMessage: "By clicking on « Sign up », I declare that I have read the <var1> General Conditions of Use </var1> of the debate space and accept them",
|
|
165
|
-
values: {
|
|
166
|
-
var1: (t) => /* @__PURE__ */ e(
|
|
167
|
-
"a",
|
|
168
|
-
{
|
|
169
|
-
className: a.termsTarget,
|
|
170
|
-
target: "_blank",
|
|
171
|
-
href: N,
|
|
172
|
-
rel: "noreferrer",
|
|
173
|
-
children: t
|
|
174
|
-
}
|
|
175
|
-
)
|
|
176
|
-
}
|
|
177
|
-
}
|
|
178
|
-
) }),
|
|
179
|
-
/* @__PURE__ */ e("div", { className: a.cguButton, children: /* @__PURE__ */ e(
|
|
180
|
-
w,
|
|
138
|
+
x ? null : /* @__PURE__ */ o(d, { children: [
|
|
139
|
+
g ? /* @__PURE__ */ e("div", { className: Y(a.switchBox), children: /* @__PURE__ */ e(
|
|
140
|
+
$,
|
|
181
141
|
{
|
|
182
|
-
|
|
183
|
-
|
|
142
|
+
type: "checkbox",
|
|
143
|
+
name: "accepts_provider_email",
|
|
144
|
+
style: { fontSize: 18 },
|
|
145
|
+
checked: h,
|
|
146
|
+
label: n.formatMessage(
|
|
147
|
+
{
|
|
148
|
+
id: "auth.sso_form.consent_label",
|
|
149
|
+
defaultMessage: "I agree to receive emails from the editor"
|
|
150
|
+
},
|
|
151
|
+
{ variable: c }
|
|
152
|
+
),
|
|
153
|
+
onInputChanged: (t) => C(!h),
|
|
154
|
+
"data-testid": "accepts-email-input"
|
|
184
155
|
}
|
|
185
|
-
) })
|
|
156
|
+
) }) : null,
|
|
157
|
+
A ? /* @__PURE__ */ e("div", { className: a.error, children: n.formatMessage({
|
|
158
|
+
id: "auth.sso_form.error",
|
|
159
|
+
defaultMessage: "An error occurred during sign in. Please try again in a few moments."
|
|
160
|
+
}) }) : null,
|
|
161
|
+
L && /* @__PURE__ */ o(d, { children: [
|
|
162
|
+
/* @__PURE__ */ e("div", { className: a.cguButton, children: /* @__PURE__ */ e(
|
|
163
|
+
w,
|
|
164
|
+
{
|
|
165
|
+
id: "auth.sso_form.terms",
|
|
166
|
+
defaultMessage: "By clicking on « Sign up », I declare that I have read the <var1> General Conditions of Use </var1> of the debate space and accept them",
|
|
167
|
+
values: {
|
|
168
|
+
var1: (t) => /* @__PURE__ */ e(
|
|
169
|
+
"a",
|
|
170
|
+
{
|
|
171
|
+
className: a.termsTarget,
|
|
172
|
+
target: "_blank",
|
|
173
|
+
href: N,
|
|
174
|
+
rel: "noreferrer",
|
|
175
|
+
children: t
|
|
176
|
+
}
|
|
177
|
+
)
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
) }),
|
|
181
|
+
/* @__PURE__ */ e("div", { className: a.cguButton, children: /* @__PURE__ */ e(
|
|
182
|
+
w,
|
|
183
|
+
{
|
|
184
|
+
id: "auth.sso_form.data_terms",
|
|
185
|
+
defaultMessage: "Your personal data are being processed by the Editor. For more information and to exercise your rights, see our personal data policy available on the site."
|
|
186
|
+
}
|
|
187
|
+
) })
|
|
188
|
+
] })
|
|
186
189
|
] })
|
|
187
190
|
] })
|
|
188
191
|
] })
|
|
189
192
|
] });
|
|
190
193
|
};
|
|
191
194
|
export {
|
|
192
|
-
|
|
195
|
+
ne as SSOForm
|
|
193
196
|
};
|