@panneau/form-auth 1.0.0-alpha.237 → 1.0.0-alpha.241

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.
Files changed (3) hide show
  1. package/es/index.js +272 -42
  2. package/lib/index.js +275 -42
  3. package/package.json +7 -5
package/es/index.js CHANGED
@@ -4,19 +4,72 @@ import Form from '@panneau/form';
4
4
  import PropTypes from 'prop-types';
5
5
  import React from 'react';
6
6
  import { FormattedMessage } from 'react-intl';
7
+ import { Link } from 'react-router-dom';
7
8
 
8
- var _excluded$2 = ["action", "fields", "emailLabel", "submitButtonLabel", "size", "withLoginLink", "loginLink", "loginLabel"];
9
- var propTypes$2 = {
10
- action: PropTypes.string.isRequired,
9
+ var _excluded$5 = ["action", "fields", "size", "passwordLabel", "submitButtonLabel"];
10
+ var propTypes$5 = {
11
+ action: PropTypes.string,
12
+ fields: PropTypes$1.fields,
13
+ size: PropTypes.string,
14
+ passwordLabel: PropTypes$1.label,
15
+ submitButtonLabel: PropTypes$1.label
16
+ };
17
+ var defaultProps$5 = {
18
+ action: '/user/confirm-password',
19
+ fields: null,
20
+ size: 'lg',
21
+ passwordLabel: /*#__PURE__*/React.createElement(FormattedMessage, {
22
+ id: "B1h3gd",
23
+ defaultMessage: [{
24
+ "type": 0,
25
+ "value": "Please enter your password to continue"
26
+ }]
27
+ }),
28
+ submitButtonLabel: /*#__PURE__*/React.createElement(FormattedMessage, {
29
+ id: "RRwdkV",
30
+ defaultMessage: [{
31
+ "type": 0,
32
+ "value": "Contnue"
33
+ }]
34
+ })
35
+ };
36
+
37
+ var ConfirmPassword = function ConfirmPassword(_ref) {
38
+ var action = _ref.action,
39
+ fields = _ref.fields,
40
+ size = _ref.size,
41
+ passwordLabel = _ref.passwordLabel,
42
+ submitButtonLabel = _ref.submitButtonLabel,
43
+ props = _objectWithoutProperties(_ref, _excluded$5);
44
+
45
+ return /*#__PURE__*/React.createElement(Form, Object.assign({
46
+ action: action,
47
+ fields: fields || [{
48
+ name: 'password',
49
+ type: 'password',
50
+ size: size,
51
+ label: passwordLabel
52
+ }],
53
+ submitButtonLabel: submitButtonLabel
54
+ }, props));
55
+ };
56
+
57
+ ConfirmPassword.propTypes = propTypes$5;
58
+ ConfirmPassword.defaultProps = defaultProps$5;
59
+
60
+ var _excluded$4 = ["action", "fields", "emailLabel", "submitButtonLabel", "size", "withLoginLink", "loginLink", "loginLabel"];
61
+ var propTypes$4 = {
62
+ action: PropTypes.string,
11
63
  fields: PropTypes$1.fields,
12
64
  size: PropTypes.string,
13
- emailLabel: PropTypes$1.message,
14
- submitButtonLabel: PropTypes$1.message,
65
+ emailLabel: PropTypes$1.label,
66
+ submitButtonLabel: PropTypes$1.label,
15
67
  withLoginLink: PropTypes.bool,
16
68
  loginLink: PropTypes.string,
17
- loginLabel: PropTypes$1.message
69
+ loginLabel: PropTypes$1.label
18
70
  };
19
- var defaultProps$2 = {
71
+ var defaultProps$4 = {
72
+ action: '/forgot-password',
20
73
  fields: null,
21
74
  size: 'lg',
22
75
  emailLabel: /*#__PURE__*/React.createElement(FormattedMessage, {
@@ -36,7 +89,7 @@ var defaultProps$2 = {
36
89
  withLoginLink: true,
37
90
  loginLink: '/login',
38
91
  loginLabel: /*#__PURE__*/React.createElement(FormattedMessage, {
39
- id: "X4fQOn",
92
+ id: "tPeIKO",
40
93
  defaultMessage: [{
41
94
  "type": 0,
42
95
  "value": "Go back to login"
@@ -53,7 +106,7 @@ var ForgotPassword = function ForgotPassword(_ref) {
53
106
  withLoginLink = _ref.withLoginLink,
54
107
  loginLink = _ref.loginLink,
55
108
  loginLabel = _ref.loginLabel,
56
- props = _objectWithoutProperties(_ref, _excluded$2);
109
+ props = _objectWithoutProperties(_ref, _excluded$4);
57
110
 
58
111
  return /*#__PURE__*/React.createElement(Form, Object.assign({
59
112
  action: action,
@@ -64,29 +117,29 @@ var ForgotPassword = function ForgotPassword(_ref) {
64
117
  label: emailLabel
65
118
  }],
66
119
  submitButtonLabel: submitButtonLabel,
67
- actions: withLoginLink ? /*#__PURE__*/React.createElement("a", {
68
- className: "py-2 px-5",
69
- href: loginLink
120
+ actions: withLoginLink ? /*#__PURE__*/React.createElement(Link, {
121
+ className: "py-2 px-4",
122
+ to: loginLink
70
123
  }, loginLabel) : null
71
124
  }, props));
72
125
  };
73
126
 
74
- ForgotPassword.propTypes = propTypes$2;
75
- ForgotPassword.defaultProps = defaultProps$2;
127
+ ForgotPassword.propTypes = propTypes$4;
128
+ ForgotPassword.defaultProps = defaultProps$4;
76
129
 
77
- var _excluded$1 = ["action", "fields", "size", "emailLabel", "passwordLabel", "submitButtonLabel", "withForgotPassword", "forgotPasswordLink", "forgotPasswordLabel"];
78
- var propTypes$1 = {
130
+ var _excluded$3 = ["action", "fields", "size", "emailLabel", "passwordLabel", "submitButtonLabel", "withForgotPassword", "forgotPasswordLink", "forgotPasswordLabel"];
131
+ var propTypes$3 = {
79
132
  action: PropTypes.string,
80
133
  fields: PropTypes$1.fields,
81
134
  size: PropTypes.string,
82
- emailLabel: PropTypes$1.message,
83
- passwordLabel: PropTypes$1.message,
84
- submitButtonLabel: PropTypes$1.message,
135
+ emailLabel: PropTypes$1.label,
136
+ passwordLabel: PropTypes$1.label,
137
+ submitButtonLabel: PropTypes$1.label,
85
138
  withForgotPassword: PropTypes.bool,
86
139
  forgotPasswordLink: PropTypes.string,
87
- forgotPasswordLabel: PropTypes$1.message
140
+ forgotPasswordLabel: PropTypes$1.label
88
141
  };
89
- var defaultProps$1 = {
142
+ var defaultProps$3 = {
90
143
  action: '/login',
91
144
  fields: null,
92
145
  size: 'lg',
@@ -114,7 +167,7 @@ var defaultProps$1 = {
114
167
  withForgotPassword: true,
115
168
  forgotPasswordLink: '/forgot-password',
116
169
  forgotPasswordLabel: /*#__PURE__*/React.createElement(FormattedMessage, {
117
- id: "oKZDBl",
170
+ id: "ZBNqY2",
118
171
  defaultMessage: [{
119
172
  "type": 0,
120
173
  "value": "Forgot your password?"
@@ -122,7 +175,7 @@ var defaultProps$1 = {
122
175
  })
123
176
  };
124
177
 
125
- var LoginForm = function LoginForm(_ref) {
178
+ var Login = function Login(_ref) {
126
179
  var action = _ref.action,
127
180
  fields = _ref.fields,
128
181
  size = _ref.size,
@@ -132,7 +185,7 @@ var LoginForm = function LoginForm(_ref) {
132
185
  withForgotPassword = _ref.withForgotPassword,
133
186
  forgotPasswordLink = _ref.forgotPasswordLink,
134
187
  forgotPasswordLabel = _ref.forgotPasswordLabel,
135
- props = _objectWithoutProperties(_ref, _excluded$1);
188
+ props = _objectWithoutProperties(_ref, _excluded$3);
136
189
 
137
190
  return /*#__PURE__*/React.createElement(Form, Object.assign({
138
191
  action: action,
@@ -148,28 +201,48 @@ var LoginForm = function LoginForm(_ref) {
148
201
  label: passwordLabel
149
202
  }],
150
203
  submitButtonLabel: submitButtonLabel,
151
- actions: withForgotPassword ? /*#__PURE__*/React.createElement("a", {
152
- className: "py-2 px-5",
153
- href: forgotPasswordLink
204
+ actions: withForgotPassword ? /*#__PURE__*/React.createElement(Link, {
205
+ className: "py-2 px-4",
206
+ to: forgotPasswordLink
154
207
  }, forgotPasswordLabel) : null
155
208
  }, props));
156
209
  };
157
210
 
158
- LoginForm.propTypes = propTypes$1;
159
- LoginForm.defaultProps = defaultProps$1;
211
+ Login.propTypes = propTypes$3;
212
+ Login.defaultProps = defaultProps$3;
160
213
 
161
- var _excluded = ["action", "fields", "size", "passwordLabel", "passwordConfirmationLabel", "submitButtonLabel"];
162
- var propTypes = {
163
- action: PropTypes.string.isRequired,
214
+ var _excluded$2 = ["action", "fields", "size", "nameLabel", "emailLabel", "passwordLabel", "passwordConfirmationLabel", "submitButtonLabel", "withLoginLink", "loginLink", "loginLabel"];
215
+ var propTypes$2 = {
216
+ action: PropTypes.string,
164
217
  fields: PropTypes$1.fields,
165
218
  size: PropTypes.string,
166
- passwordLabel: PropTypes$1.message,
167
- passwordConfirmationLabel: PropTypes$1.message,
168
- submitButtonLabel: PropTypes$1.message
219
+ nameLabel: PropTypes$1.label,
220
+ emailLabel: PropTypes$1.label,
221
+ passwordLabel: PropTypes$1.label,
222
+ passwordConfirmationLabel: PropTypes$1.label,
223
+ submitButtonLabel: PropTypes$1.label,
224
+ withLoginLink: PropTypes.bool,
225
+ loginLink: PropTypes.string,
226
+ loginLabel: PropTypes$1.label
169
227
  };
170
- var defaultProps = {
228
+ var defaultProps$2 = {
229
+ action: '/register',
171
230
  fields: null,
172
231
  size: 'lg',
232
+ nameLabel: /*#__PURE__*/React.createElement(FormattedMessage, {
233
+ id: "UUv8FR",
234
+ defaultMessage: [{
235
+ "type": 0,
236
+ "value": "Name"
237
+ }]
238
+ }),
239
+ emailLabel: /*#__PURE__*/React.createElement(FormattedMessage, {
240
+ id: "LI0Gz4",
241
+ defaultMessage: [{
242
+ "type": 0,
243
+ "value": "Email"
244
+ }]
245
+ }),
173
246
  passwordLabel: /*#__PURE__*/React.createElement(FormattedMessage, {
174
247
  id: "4yfet+",
175
248
  defaultMessage: [{
@@ -178,10 +251,103 @@ var defaultProps = {
178
251
  }]
179
252
  }),
180
253
  passwordConfirmationLabel: /*#__PURE__*/React.createElement(FormattedMessage, {
181
- id: "SdtI90",
254
+ id: "VhJUeW",
182
255
  defaultMessage: [{
183
256
  "type": 0,
184
- "value": "Password confirmation"
257
+ "value": "Confirm your password"
258
+ }]
259
+ }),
260
+ submitButtonLabel: /*#__PURE__*/React.createElement(FormattedMessage, {
261
+ id: "PQX/ph",
262
+ defaultMessage: [{
263
+ "type": 0,
264
+ "value": "Create account"
265
+ }]
266
+ }),
267
+ withLoginLink: true,
268
+ loginLink: '/forgot-password',
269
+ loginLabel: /*#__PURE__*/React.createElement(FormattedMessage, {
270
+ id: "wa783M",
271
+ defaultMessage: [{
272
+ "type": 0,
273
+ "value": "Already have an account? Go to login"
274
+ }]
275
+ })
276
+ };
277
+
278
+ var Register = function Register(_ref) {
279
+ var action = _ref.action,
280
+ fields = _ref.fields,
281
+ size = _ref.size,
282
+ nameLabel = _ref.nameLabel,
283
+ emailLabel = _ref.emailLabel,
284
+ passwordLabel = _ref.passwordLabel,
285
+ passwordConfirmationLabel = _ref.passwordConfirmationLabel,
286
+ submitButtonLabel = _ref.submitButtonLabel,
287
+ withLoginLink = _ref.withLoginLink,
288
+ loginLink = _ref.loginLink,
289
+ loginLabel = _ref.loginLabel,
290
+ props = _objectWithoutProperties(_ref, _excluded$2);
291
+
292
+ return /*#__PURE__*/React.createElement(Form, Object.assign({
293
+ action: action,
294
+ fields: fields || [{
295
+ name: 'name',
296
+ type: 'text',
297
+ size: size,
298
+ label: nameLabel
299
+ }, {
300
+ name: 'email',
301
+ type: 'email',
302
+ size: size,
303
+ label: emailLabel
304
+ }, {
305
+ name: 'password',
306
+ type: 'password',
307
+ size: size,
308
+ label: passwordLabel
309
+ }, {
310
+ name: 'password_confirmation',
311
+ type: 'password',
312
+ size: size,
313
+ label: passwordConfirmationLabel
314
+ }],
315
+ submitButtonLabel: submitButtonLabel,
316
+ actions: withLoginLink ? /*#__PURE__*/React.createElement(Link, {
317
+ className: "py-2 px-4",
318
+ to: loginLink
319
+ }, loginLabel) : null
320
+ }, props));
321
+ };
322
+
323
+ Register.propTypes = propTypes$2;
324
+ Register.defaultProps = defaultProps$2;
325
+
326
+ var _excluded$1 = ["action", "fields", "size", "passwordLabel", "passwordConfirmationLabel", "submitButtonLabel"];
327
+ var propTypes$1 = {
328
+ action: PropTypes.string,
329
+ fields: PropTypes$1.fields,
330
+ size: PropTypes.string,
331
+ passwordLabel: PropTypes$1.label,
332
+ passwordConfirmationLabel: PropTypes$1.label,
333
+ submitButtonLabel: PropTypes$1.label
334
+ };
335
+ var defaultProps$1 = {
336
+ action: '/reset-password',
337
+ fields: null,
338
+ size: 'lg',
339
+ passwordLabel: /*#__PURE__*/React.createElement(FormattedMessage, {
340
+ id: "4yfet+",
341
+ defaultMessage: [{
342
+ "type": 0,
343
+ "value": "Password"
344
+ }]
345
+ }),
346
+ passwordConfirmationLabel: /*#__PURE__*/React.createElement(FormattedMessage, {
347
+ id: "VhJUeW",
348
+ defaultMessage: [{
349
+ "type": 0,
350
+ "value": "Confirm your password"
185
351
  }]
186
352
  }),
187
353
  submitButtonLabel: /*#__PURE__*/React.createElement(FormattedMessage, {
@@ -200,7 +366,7 @@ var ResetPassword = function ResetPassword(_ref) {
200
366
  passwordLabel = _ref.passwordLabel,
201
367
  passwordConfirmationLabel = _ref.passwordConfirmationLabel,
202
368
  submitButtonLabel = _ref.submitButtonLabel,
203
- props = _objectWithoutProperties(_ref, _excluded);
369
+ props = _objectWithoutProperties(_ref, _excluded$1);
204
370
 
205
371
  return /*#__PURE__*/React.createElement(Form, Object.assign({
206
372
  action: action,
@@ -219,7 +385,71 @@ var ResetPassword = function ResetPassword(_ref) {
219
385
  }, props));
220
386
  };
221
387
 
222
- ResetPassword.propTypes = propTypes;
223
- ResetPassword.defaultProps = defaultProps;
388
+ ResetPassword.propTypes = propTypes$1;
389
+ ResetPassword.defaultProps = defaultProps$1;
390
+
391
+ var _excluded = ["action", "fields", "explainationLabel", "submitButtonLabel", "size", "withSkipLink", "skipLink", "skipLabel"];
392
+ var propTypes = {
393
+ action: PropTypes.string,
394
+ fields: PropTypes$1.fields,
395
+ size: PropTypes.string,
396
+ explainationLabel: PropTypes$1.label,
397
+ submitButtonLabel: PropTypes$1.label,
398
+ withSkipLink: PropTypes.bool,
399
+ skipLink: PropTypes.string,
400
+ skipLabel: PropTypes$1.label
401
+ };
402
+ var defaultProps = {
403
+ action: '/user/two-factor-authentication',
404
+ fields: null,
405
+ size: 'lg',
406
+ explainationLabel: /*#__PURE__*/React.createElement(FormattedMessage, {
407
+ id: "zTiC4D",
408
+ defaultMessage: [{
409
+ "type": 0,
410
+ "value": "Do you wish to enable two factor authentication on your account? You will have to use an authentication app such as Google Authenticator or Microsoft Authenticator in addition to your password to connect."
411
+ }]
412
+ }),
413
+ submitButtonLabel: /*#__PURE__*/React.createElement(FormattedMessage, {
414
+ id: "gj67c0",
415
+ defaultMessage: [{
416
+ "type": 0,
417
+ "value": "Enable Two Factor authentication"
418
+ }]
419
+ }),
420
+ withSkipLink: true,
421
+ skipLink: '/home',
422
+ skipLabel: /*#__PURE__*/React.createElement(FormattedMessage, {
423
+ id: "li2Qqu",
424
+ defaultMessage: [{
425
+ "type": 0,
426
+ "value": "Skip setup"
427
+ }]
428
+ })
429
+ };
430
+
431
+ var TwoFactor = function TwoFactor(_ref) {
432
+ var action = _ref.action;
433
+ _ref.fields;
434
+ var explainationLabel = _ref.explainationLabel,
435
+ submitButtonLabel = _ref.submitButtonLabel;
436
+ _ref.size;
437
+ var withSkipLink = _ref.withSkipLink,
438
+ skipLink = _ref.skipLink,
439
+ skipLabel = _ref.skipLabel,
440
+ props = _objectWithoutProperties(_ref, _excluded);
441
+
442
+ return /*#__PURE__*/React.createElement(Form, Object.assign({
443
+ action: action,
444
+ submitButtonLabel: submitButtonLabel,
445
+ actions: withSkipLink ? /*#__PURE__*/React.createElement(Link, {
446
+ className: "py-2 px-4",
447
+ to: skipLink
448
+ }, skipLabel) : null
449
+ }, props), /*#__PURE__*/React.createElement("p", null, explainationLabel));
450
+ };
451
+
452
+ TwoFactor.propTypes = propTypes;
453
+ TwoFactor.defaultProps = defaultProps;
224
454
 
225
- export { ForgotPassword, LoginForm as Login, ResetPassword };
455
+ export { ConfirmPassword, ForgotPassword, Login, Register, ResetPassword, TwoFactor };
package/lib/index.js CHANGED
@@ -8,6 +8,7 @@ var Form = require('@panneau/form');
8
8
  var PropTypes = require('prop-types');
9
9
  var React = require('react');
10
10
  var reactIntl = require('react-intl');
11
+ var reactRouterDom = require('react-router-dom');
11
12
 
12
13
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
13
14
 
@@ -16,18 +17,70 @@ var Form__default = /*#__PURE__*/_interopDefaultLegacy(Form);
16
17
  var PropTypes__default = /*#__PURE__*/_interopDefaultLegacy(PropTypes);
17
18
  var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
18
19
 
19
- var _excluded$2 = ["action", "fields", "emailLabel", "submitButtonLabel", "size", "withLoginLink", "loginLink", "loginLabel"];
20
- var propTypes$2 = {
21
- action: PropTypes__default["default"].string.isRequired,
20
+ var _excluded$5 = ["action", "fields", "size", "passwordLabel", "submitButtonLabel"];
21
+ var propTypes$5 = {
22
+ action: PropTypes__default["default"].string,
23
+ fields: core.PropTypes.fields,
24
+ size: PropTypes__default["default"].string,
25
+ passwordLabel: core.PropTypes.label,
26
+ submitButtonLabel: core.PropTypes.label
27
+ };
28
+ var defaultProps$5 = {
29
+ action: '/user/confirm-password',
30
+ fields: null,
31
+ size: 'lg',
32
+ passwordLabel: /*#__PURE__*/React__default["default"].createElement(reactIntl.FormattedMessage, {
33
+ id: "B1h3gd",
34
+ defaultMessage: [{
35
+ "type": 0,
36
+ "value": "Please enter your password to continue"
37
+ }]
38
+ }),
39
+ submitButtonLabel: /*#__PURE__*/React__default["default"].createElement(reactIntl.FormattedMessage, {
40
+ id: "RRwdkV",
41
+ defaultMessage: [{
42
+ "type": 0,
43
+ "value": "Contnue"
44
+ }]
45
+ })
46
+ };
47
+
48
+ var ConfirmPassword = function ConfirmPassword(_ref) {
49
+ var action = _ref.action,
50
+ fields = _ref.fields,
51
+ size = _ref.size,
52
+ passwordLabel = _ref.passwordLabel,
53
+ submitButtonLabel = _ref.submitButtonLabel,
54
+ props = _objectWithoutProperties__default["default"](_ref, _excluded$5);
55
+
56
+ return /*#__PURE__*/React__default["default"].createElement(Form__default["default"], Object.assign({
57
+ action: action,
58
+ fields: fields || [{
59
+ name: 'password',
60
+ type: 'password',
61
+ size: size,
62
+ label: passwordLabel
63
+ }],
64
+ submitButtonLabel: submitButtonLabel
65
+ }, props));
66
+ };
67
+
68
+ ConfirmPassword.propTypes = propTypes$5;
69
+ ConfirmPassword.defaultProps = defaultProps$5;
70
+
71
+ var _excluded$4 = ["action", "fields", "emailLabel", "submitButtonLabel", "size", "withLoginLink", "loginLink", "loginLabel"];
72
+ var propTypes$4 = {
73
+ action: PropTypes__default["default"].string,
22
74
  fields: core.PropTypes.fields,
23
75
  size: PropTypes__default["default"].string,
24
- emailLabel: core.PropTypes.message,
25
- submitButtonLabel: core.PropTypes.message,
76
+ emailLabel: core.PropTypes.label,
77
+ submitButtonLabel: core.PropTypes.label,
26
78
  withLoginLink: PropTypes__default["default"].bool,
27
79
  loginLink: PropTypes__default["default"].string,
28
- loginLabel: core.PropTypes.message
80
+ loginLabel: core.PropTypes.label
29
81
  };
30
- var defaultProps$2 = {
82
+ var defaultProps$4 = {
83
+ action: '/forgot-password',
31
84
  fields: null,
32
85
  size: 'lg',
33
86
  emailLabel: /*#__PURE__*/React__default["default"].createElement(reactIntl.FormattedMessage, {
@@ -47,7 +100,7 @@ var defaultProps$2 = {
47
100
  withLoginLink: true,
48
101
  loginLink: '/login',
49
102
  loginLabel: /*#__PURE__*/React__default["default"].createElement(reactIntl.FormattedMessage, {
50
- id: "X4fQOn",
103
+ id: "tPeIKO",
51
104
  defaultMessage: [{
52
105
  "type": 0,
53
106
  "value": "Go back to login"
@@ -64,7 +117,7 @@ var ForgotPassword = function ForgotPassword(_ref) {
64
117
  withLoginLink = _ref.withLoginLink,
65
118
  loginLink = _ref.loginLink,
66
119
  loginLabel = _ref.loginLabel,
67
- props = _objectWithoutProperties__default["default"](_ref, _excluded$2);
120
+ props = _objectWithoutProperties__default["default"](_ref, _excluded$4);
68
121
 
69
122
  return /*#__PURE__*/React__default["default"].createElement(Form__default["default"], Object.assign({
70
123
  action: action,
@@ -75,29 +128,29 @@ var ForgotPassword = function ForgotPassword(_ref) {
75
128
  label: emailLabel
76
129
  }],
77
130
  submitButtonLabel: submitButtonLabel,
78
- actions: withLoginLink ? /*#__PURE__*/React__default["default"].createElement("a", {
79
- className: "py-2 px-5",
80
- href: loginLink
131
+ actions: withLoginLink ? /*#__PURE__*/React__default["default"].createElement(reactRouterDom.Link, {
132
+ className: "py-2 px-4",
133
+ to: loginLink
81
134
  }, loginLabel) : null
82
135
  }, props));
83
136
  };
84
137
 
85
- ForgotPassword.propTypes = propTypes$2;
86
- ForgotPassword.defaultProps = defaultProps$2;
138
+ ForgotPassword.propTypes = propTypes$4;
139
+ ForgotPassword.defaultProps = defaultProps$4;
87
140
 
88
- var _excluded$1 = ["action", "fields", "size", "emailLabel", "passwordLabel", "submitButtonLabel", "withForgotPassword", "forgotPasswordLink", "forgotPasswordLabel"];
89
- var propTypes$1 = {
141
+ var _excluded$3 = ["action", "fields", "size", "emailLabel", "passwordLabel", "submitButtonLabel", "withForgotPassword", "forgotPasswordLink", "forgotPasswordLabel"];
142
+ var propTypes$3 = {
90
143
  action: PropTypes__default["default"].string,
91
144
  fields: core.PropTypes.fields,
92
145
  size: PropTypes__default["default"].string,
93
- emailLabel: core.PropTypes.message,
94
- passwordLabel: core.PropTypes.message,
95
- submitButtonLabel: core.PropTypes.message,
146
+ emailLabel: core.PropTypes.label,
147
+ passwordLabel: core.PropTypes.label,
148
+ submitButtonLabel: core.PropTypes.label,
96
149
  withForgotPassword: PropTypes__default["default"].bool,
97
150
  forgotPasswordLink: PropTypes__default["default"].string,
98
- forgotPasswordLabel: core.PropTypes.message
151
+ forgotPasswordLabel: core.PropTypes.label
99
152
  };
100
- var defaultProps$1 = {
153
+ var defaultProps$3 = {
101
154
  action: '/login',
102
155
  fields: null,
103
156
  size: 'lg',
@@ -125,7 +178,7 @@ var defaultProps$1 = {
125
178
  withForgotPassword: true,
126
179
  forgotPasswordLink: '/forgot-password',
127
180
  forgotPasswordLabel: /*#__PURE__*/React__default["default"].createElement(reactIntl.FormattedMessage, {
128
- id: "oKZDBl",
181
+ id: "ZBNqY2",
129
182
  defaultMessage: [{
130
183
  "type": 0,
131
184
  "value": "Forgot your password?"
@@ -133,7 +186,7 @@ var defaultProps$1 = {
133
186
  })
134
187
  };
135
188
 
136
- var LoginForm = function LoginForm(_ref) {
189
+ var Login = function Login(_ref) {
137
190
  var action = _ref.action,
138
191
  fields = _ref.fields,
139
192
  size = _ref.size,
@@ -143,7 +196,7 @@ var LoginForm = function LoginForm(_ref) {
143
196
  withForgotPassword = _ref.withForgotPassword,
144
197
  forgotPasswordLink = _ref.forgotPasswordLink,
145
198
  forgotPasswordLabel = _ref.forgotPasswordLabel,
146
- props = _objectWithoutProperties__default["default"](_ref, _excluded$1);
199
+ props = _objectWithoutProperties__default["default"](_ref, _excluded$3);
147
200
 
148
201
  return /*#__PURE__*/React__default["default"].createElement(Form__default["default"], Object.assign({
149
202
  action: action,
@@ -159,28 +212,48 @@ var LoginForm = function LoginForm(_ref) {
159
212
  label: passwordLabel
160
213
  }],
161
214
  submitButtonLabel: submitButtonLabel,
162
- actions: withForgotPassword ? /*#__PURE__*/React__default["default"].createElement("a", {
163
- className: "py-2 px-5",
164
- href: forgotPasswordLink
215
+ actions: withForgotPassword ? /*#__PURE__*/React__default["default"].createElement(reactRouterDom.Link, {
216
+ className: "py-2 px-4",
217
+ to: forgotPasswordLink
165
218
  }, forgotPasswordLabel) : null
166
219
  }, props));
167
220
  };
168
221
 
169
- LoginForm.propTypes = propTypes$1;
170
- LoginForm.defaultProps = defaultProps$1;
222
+ Login.propTypes = propTypes$3;
223
+ Login.defaultProps = defaultProps$3;
171
224
 
172
- var _excluded = ["action", "fields", "size", "passwordLabel", "passwordConfirmationLabel", "submitButtonLabel"];
173
- var propTypes = {
174
- action: PropTypes__default["default"].string.isRequired,
225
+ var _excluded$2 = ["action", "fields", "size", "nameLabel", "emailLabel", "passwordLabel", "passwordConfirmationLabel", "submitButtonLabel", "withLoginLink", "loginLink", "loginLabel"];
226
+ var propTypes$2 = {
227
+ action: PropTypes__default["default"].string,
175
228
  fields: core.PropTypes.fields,
176
229
  size: PropTypes__default["default"].string,
177
- passwordLabel: core.PropTypes.message,
178
- passwordConfirmationLabel: core.PropTypes.message,
179
- submitButtonLabel: core.PropTypes.message
230
+ nameLabel: core.PropTypes.label,
231
+ emailLabel: core.PropTypes.label,
232
+ passwordLabel: core.PropTypes.label,
233
+ passwordConfirmationLabel: core.PropTypes.label,
234
+ submitButtonLabel: core.PropTypes.label,
235
+ withLoginLink: PropTypes__default["default"].bool,
236
+ loginLink: PropTypes__default["default"].string,
237
+ loginLabel: core.PropTypes.label
180
238
  };
181
- var defaultProps = {
239
+ var defaultProps$2 = {
240
+ action: '/register',
182
241
  fields: null,
183
242
  size: 'lg',
243
+ nameLabel: /*#__PURE__*/React__default["default"].createElement(reactIntl.FormattedMessage, {
244
+ id: "UUv8FR",
245
+ defaultMessage: [{
246
+ "type": 0,
247
+ "value": "Name"
248
+ }]
249
+ }),
250
+ emailLabel: /*#__PURE__*/React__default["default"].createElement(reactIntl.FormattedMessage, {
251
+ id: "LI0Gz4",
252
+ defaultMessage: [{
253
+ "type": 0,
254
+ "value": "Email"
255
+ }]
256
+ }),
184
257
  passwordLabel: /*#__PURE__*/React__default["default"].createElement(reactIntl.FormattedMessage, {
185
258
  id: "4yfet+",
186
259
  defaultMessage: [{
@@ -189,10 +262,103 @@ var defaultProps = {
189
262
  }]
190
263
  }),
191
264
  passwordConfirmationLabel: /*#__PURE__*/React__default["default"].createElement(reactIntl.FormattedMessage, {
192
- id: "SdtI90",
265
+ id: "VhJUeW",
193
266
  defaultMessage: [{
194
267
  "type": 0,
195
- "value": "Password confirmation"
268
+ "value": "Confirm your password"
269
+ }]
270
+ }),
271
+ submitButtonLabel: /*#__PURE__*/React__default["default"].createElement(reactIntl.FormattedMessage, {
272
+ id: "PQX/ph",
273
+ defaultMessage: [{
274
+ "type": 0,
275
+ "value": "Create account"
276
+ }]
277
+ }),
278
+ withLoginLink: true,
279
+ loginLink: '/forgot-password',
280
+ loginLabel: /*#__PURE__*/React__default["default"].createElement(reactIntl.FormattedMessage, {
281
+ id: "wa783M",
282
+ defaultMessage: [{
283
+ "type": 0,
284
+ "value": "Already have an account? Go to login"
285
+ }]
286
+ })
287
+ };
288
+
289
+ var Register = function Register(_ref) {
290
+ var action = _ref.action,
291
+ fields = _ref.fields,
292
+ size = _ref.size,
293
+ nameLabel = _ref.nameLabel,
294
+ emailLabel = _ref.emailLabel,
295
+ passwordLabel = _ref.passwordLabel,
296
+ passwordConfirmationLabel = _ref.passwordConfirmationLabel,
297
+ submitButtonLabel = _ref.submitButtonLabel,
298
+ withLoginLink = _ref.withLoginLink,
299
+ loginLink = _ref.loginLink,
300
+ loginLabel = _ref.loginLabel,
301
+ props = _objectWithoutProperties__default["default"](_ref, _excluded$2);
302
+
303
+ return /*#__PURE__*/React__default["default"].createElement(Form__default["default"], Object.assign({
304
+ action: action,
305
+ fields: fields || [{
306
+ name: 'name',
307
+ type: 'text',
308
+ size: size,
309
+ label: nameLabel
310
+ }, {
311
+ name: 'email',
312
+ type: 'email',
313
+ size: size,
314
+ label: emailLabel
315
+ }, {
316
+ name: 'password',
317
+ type: 'password',
318
+ size: size,
319
+ label: passwordLabel
320
+ }, {
321
+ name: 'password_confirmation',
322
+ type: 'password',
323
+ size: size,
324
+ label: passwordConfirmationLabel
325
+ }],
326
+ submitButtonLabel: submitButtonLabel,
327
+ actions: withLoginLink ? /*#__PURE__*/React__default["default"].createElement(reactRouterDom.Link, {
328
+ className: "py-2 px-4",
329
+ to: loginLink
330
+ }, loginLabel) : null
331
+ }, props));
332
+ };
333
+
334
+ Register.propTypes = propTypes$2;
335
+ Register.defaultProps = defaultProps$2;
336
+
337
+ var _excluded$1 = ["action", "fields", "size", "passwordLabel", "passwordConfirmationLabel", "submitButtonLabel"];
338
+ var propTypes$1 = {
339
+ action: PropTypes__default["default"].string,
340
+ fields: core.PropTypes.fields,
341
+ size: PropTypes__default["default"].string,
342
+ passwordLabel: core.PropTypes.label,
343
+ passwordConfirmationLabel: core.PropTypes.label,
344
+ submitButtonLabel: core.PropTypes.label
345
+ };
346
+ var defaultProps$1 = {
347
+ action: '/reset-password',
348
+ fields: null,
349
+ size: 'lg',
350
+ passwordLabel: /*#__PURE__*/React__default["default"].createElement(reactIntl.FormattedMessage, {
351
+ id: "4yfet+",
352
+ defaultMessage: [{
353
+ "type": 0,
354
+ "value": "Password"
355
+ }]
356
+ }),
357
+ passwordConfirmationLabel: /*#__PURE__*/React__default["default"].createElement(reactIntl.FormattedMessage, {
358
+ id: "VhJUeW",
359
+ defaultMessage: [{
360
+ "type": 0,
361
+ "value": "Confirm your password"
196
362
  }]
197
363
  }),
198
364
  submitButtonLabel: /*#__PURE__*/React__default["default"].createElement(reactIntl.FormattedMessage, {
@@ -211,7 +377,7 @@ var ResetPassword = function ResetPassword(_ref) {
211
377
  passwordLabel = _ref.passwordLabel,
212
378
  passwordConfirmationLabel = _ref.passwordConfirmationLabel,
213
379
  submitButtonLabel = _ref.submitButtonLabel,
214
- props = _objectWithoutProperties__default["default"](_ref, _excluded);
380
+ props = _objectWithoutProperties__default["default"](_ref, _excluded$1);
215
381
 
216
382
  return /*#__PURE__*/React__default["default"].createElement(Form__default["default"], Object.assign({
217
383
  action: action,
@@ -230,9 +396,76 @@ var ResetPassword = function ResetPassword(_ref) {
230
396
  }, props));
231
397
  };
232
398
 
233
- ResetPassword.propTypes = propTypes;
234
- ResetPassword.defaultProps = defaultProps;
399
+ ResetPassword.propTypes = propTypes$1;
400
+ ResetPassword.defaultProps = defaultProps$1;
401
+
402
+ var _excluded = ["action", "fields", "explainationLabel", "submitButtonLabel", "size", "withSkipLink", "skipLink", "skipLabel"];
403
+ var propTypes = {
404
+ action: PropTypes__default["default"].string,
405
+ fields: core.PropTypes.fields,
406
+ size: PropTypes__default["default"].string,
407
+ explainationLabel: core.PropTypes.label,
408
+ submitButtonLabel: core.PropTypes.label,
409
+ withSkipLink: PropTypes__default["default"].bool,
410
+ skipLink: PropTypes__default["default"].string,
411
+ skipLabel: core.PropTypes.label
412
+ };
413
+ var defaultProps = {
414
+ action: '/user/two-factor-authentication',
415
+ fields: null,
416
+ size: 'lg',
417
+ explainationLabel: /*#__PURE__*/React__default["default"].createElement(reactIntl.FormattedMessage, {
418
+ id: "zTiC4D",
419
+ defaultMessage: [{
420
+ "type": 0,
421
+ "value": "Do you wish to enable two factor authentication on your account? You will have to use an authentication app such as Google Authenticator or Microsoft Authenticator in addition to your password to connect."
422
+ }]
423
+ }),
424
+ submitButtonLabel: /*#__PURE__*/React__default["default"].createElement(reactIntl.FormattedMessage, {
425
+ id: "gj67c0",
426
+ defaultMessage: [{
427
+ "type": 0,
428
+ "value": "Enable Two Factor authentication"
429
+ }]
430
+ }),
431
+ withSkipLink: true,
432
+ skipLink: '/home',
433
+ skipLabel: /*#__PURE__*/React__default["default"].createElement(reactIntl.FormattedMessage, {
434
+ id: "li2Qqu",
435
+ defaultMessage: [{
436
+ "type": 0,
437
+ "value": "Skip setup"
438
+ }]
439
+ })
440
+ };
441
+
442
+ var TwoFactor = function TwoFactor(_ref) {
443
+ var action = _ref.action;
444
+ _ref.fields;
445
+ var explainationLabel = _ref.explainationLabel,
446
+ submitButtonLabel = _ref.submitButtonLabel;
447
+ _ref.size;
448
+ var withSkipLink = _ref.withSkipLink,
449
+ skipLink = _ref.skipLink,
450
+ skipLabel = _ref.skipLabel,
451
+ props = _objectWithoutProperties__default["default"](_ref, _excluded);
452
+
453
+ return /*#__PURE__*/React__default["default"].createElement(Form__default["default"], Object.assign({
454
+ action: action,
455
+ submitButtonLabel: submitButtonLabel,
456
+ actions: withSkipLink ? /*#__PURE__*/React__default["default"].createElement(reactRouterDom.Link, {
457
+ className: "py-2 px-4",
458
+ to: skipLink
459
+ }, skipLabel) : null
460
+ }, props), /*#__PURE__*/React__default["default"].createElement("p", null, explainationLabel));
461
+ };
462
+
463
+ TwoFactor.propTypes = propTypes;
464
+ TwoFactor.defaultProps = defaultProps;
235
465
 
466
+ exports.ConfirmPassword = ConfirmPassword;
236
467
  exports.ForgotPassword = ForgotPassword;
237
- exports.Login = LoginForm;
468
+ exports.Login = Login;
469
+ exports.Register = Register;
238
470
  exports.ResetPassword = ResetPassword;
471
+ exports.TwoFactor = TwoFactor;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@panneau/form-auth",
3
- "version": "1.0.0-alpha.237",
3
+ "version": "1.0.0-alpha.241",
4
4
  "description": "Basic forgot password form",
5
5
  "keywords": [
6
6
  "javascript"
@@ -41,19 +41,21 @@
41
41
  },
42
42
  "peerDependencies": {
43
43
  "react": "^16.8.0 || ^17.0.0",
44
- "react-dom": "^16.8.0 || ^17.0.0"
44
+ "react-dom": "^16.8.0 || ^17.0.0",
45
+ "react-router-dom": "^5.0.0 || ^6.2.1"
45
46
  },
46
47
  "dependencies": {
47
48
  "@babel/runtime": "^7.12.5",
48
49
  "@panneau/core": "^1.0.0-alpha.237",
49
- "@panneau/form": "^1.0.0-alpha.237",
50
+ "@panneau/form": "^1.0.0-alpha.238",
50
51
  "classnames": "^2.2.6",
51
52
  "lodash": "^4.17.21",
52
53
  "prop-types": "^15.7.2",
53
- "react-intl": "^5.15.8"
54
+ "react-intl": "^5.15.8",
55
+ "react-router-dom": "^5.2.0 || ^6.2.1"
54
56
  },
55
57
  "publishConfig": {
56
58
  "access": "public"
57
59
  },
58
- "gitHead": "04ba18e9dc24997f869503808313cfab7f5065b2"
60
+ "gitHead": "8f58a72c8bfeaca5418c85c53f78434e454a27de"
59
61
  }