@panneau/form-auth 1.0.0-alpha.242 → 1.0.0-alpha.243

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 +164 -39
  2. package/lib/index.js +165 -38
  3. package/package.json +3 -2
package/es/index.js CHANGED
@@ -2,19 +2,20 @@ import _objectWithoutProperties from '@babel/runtime/helpers/objectWithoutProper
2
2
  import { PropTypes as PropTypes$1 } from '@panneau/core';
3
3
  import Form from '@panneau/form';
4
4
  import PropTypes from 'prop-types';
5
- import React from 'react';
5
+ import React, { useCallback } from 'react';
6
6
  import { FormattedMessage } from 'react-intl';
7
7
  import { Link } from 'react-router-dom';
8
+ import { postJSON, getCSRFHeaders } from '@folklore/fetch';
8
9
 
9
- var _excluded$5 = ["action", "fields", "size", "passwordLabel", "submitButtonLabel"];
10
- var propTypes$5 = {
10
+ var _excluded$7 = ["action", "fields", "size", "passwordLabel", "submitButtonLabel"];
11
+ var propTypes$7 = {
11
12
  action: PropTypes.string,
12
13
  fields: PropTypes$1.fields,
13
14
  size: PropTypes.string,
14
15
  passwordLabel: PropTypes$1.label,
15
16
  submitButtonLabel: PropTypes$1.label
16
17
  };
17
- var defaultProps$5 = {
18
+ var defaultProps$7 = {
18
19
  action: '/user/confirm-password',
19
20
  fields: null,
20
21
  size: 'lg',
@@ -26,10 +27,10 @@ var defaultProps$5 = {
26
27
  }]
27
28
  }),
28
29
  submitButtonLabel: /*#__PURE__*/React.createElement(FormattedMessage, {
29
- id: "RRwdkV",
30
+ id: "QUAHwy",
30
31
  defaultMessage: [{
31
32
  "type": 0,
32
- "value": "Contnue"
33
+ "value": "Continue"
33
34
  }]
34
35
  })
35
36
  };
@@ -40,7 +41,7 @@ var ConfirmPassword = function ConfirmPassword(_ref) {
40
41
  size = _ref.size,
41
42
  passwordLabel = _ref.passwordLabel,
42
43
  submitButtonLabel = _ref.submitButtonLabel,
43
- props = _objectWithoutProperties(_ref, _excluded$5);
44
+ props = _objectWithoutProperties(_ref, _excluded$7);
44
45
 
45
46
  return /*#__PURE__*/React.createElement(Form, Object.assign({
46
47
  action: action,
@@ -54,11 +55,11 @@ var ConfirmPassword = function ConfirmPassword(_ref) {
54
55
  }, props));
55
56
  };
56
57
 
57
- ConfirmPassword.propTypes = propTypes$5;
58
- ConfirmPassword.defaultProps = defaultProps$5;
58
+ ConfirmPassword.propTypes = propTypes$7;
59
+ ConfirmPassword.defaultProps = defaultProps$7;
59
60
 
60
- var _excluded$4 = ["action", "fields", "emailLabel", "submitButtonLabel", "size", "withLoginLink", "loginLink", "loginLabel"];
61
- var propTypes$4 = {
61
+ var _excluded$6 = ["action", "fields", "emailLabel", "submitButtonLabel", "size", "withLoginLink", "loginLink", "loginLabel"];
62
+ var propTypes$6 = {
62
63
  action: PropTypes.string,
63
64
  fields: PropTypes$1.fields,
64
65
  size: PropTypes.string,
@@ -68,7 +69,7 @@ var propTypes$4 = {
68
69
  loginLink: PropTypes.string,
69
70
  loginLabel: PropTypes$1.label
70
71
  };
71
- var defaultProps$4 = {
72
+ var defaultProps$6 = {
72
73
  action: '/forgot-password',
73
74
  fields: null,
74
75
  size: 'lg',
@@ -106,7 +107,7 @@ var ForgotPassword = function ForgotPassword(_ref) {
106
107
  withLoginLink = _ref.withLoginLink,
107
108
  loginLink = _ref.loginLink,
108
109
  loginLabel = _ref.loginLabel,
109
- props = _objectWithoutProperties(_ref, _excluded$4);
110
+ props = _objectWithoutProperties(_ref, _excluded$6);
110
111
 
111
112
  return /*#__PURE__*/React.createElement(Form, Object.assign({
112
113
  action: action,
@@ -124,11 +125,11 @@ var ForgotPassword = function ForgotPassword(_ref) {
124
125
  }, props));
125
126
  };
126
127
 
127
- ForgotPassword.propTypes = propTypes$4;
128
- ForgotPassword.defaultProps = defaultProps$4;
128
+ ForgotPassword.propTypes = propTypes$6;
129
+ ForgotPassword.defaultProps = defaultProps$6;
129
130
 
130
- var _excluded$3 = ["action", "fields", "size", "emailLabel", "passwordLabel", "submitButtonLabel", "withForgotPassword", "forgotPasswordLink", "forgotPasswordLabel"];
131
- var propTypes$3 = {
131
+ var _excluded$5 = ["action", "fields", "size", "emailLabel", "passwordLabel", "submitButtonLabel", "withForgotPassword", "forgotPasswordLink", "forgotPasswordLabel"];
132
+ var propTypes$5 = {
132
133
  action: PropTypes.string,
133
134
  fields: PropTypes$1.fields,
134
135
  size: PropTypes.string,
@@ -139,7 +140,7 @@ var propTypes$3 = {
139
140
  forgotPasswordLink: PropTypes.string,
140
141
  forgotPasswordLabel: PropTypes$1.label
141
142
  };
142
- var defaultProps$3 = {
143
+ var defaultProps$5 = {
143
144
  action: '/login',
144
145
  fields: null,
145
146
  size: 'lg',
@@ -185,7 +186,7 @@ var Login = function Login(_ref) {
185
186
  withForgotPassword = _ref.withForgotPassword,
186
187
  forgotPasswordLink = _ref.forgotPasswordLink,
187
188
  forgotPasswordLabel = _ref.forgotPasswordLabel,
188
- props = _objectWithoutProperties(_ref, _excluded$3);
189
+ props = _objectWithoutProperties(_ref, _excluded$5);
189
190
 
190
191
  return /*#__PURE__*/React.createElement(Form, Object.assign({
191
192
  action: action,
@@ -208,11 +209,11 @@ var Login = function Login(_ref) {
208
209
  }, props));
209
210
  };
210
211
 
211
- Login.propTypes = propTypes$3;
212
- Login.defaultProps = defaultProps$3;
212
+ Login.propTypes = propTypes$5;
213
+ Login.defaultProps = defaultProps$5;
213
214
 
214
- var _excluded$2 = ["action", "fields", "size", "nameLabel", "emailLabel", "passwordLabel", "passwordConfirmationLabel", "submitButtonLabel", "withLoginLink", "loginLink", "loginLabel"];
215
- var propTypes$2 = {
215
+ var _excluded$4 = ["action", "fields", "size", "nameLabel", "emailLabel", "passwordLabel", "passwordConfirmationLabel", "submitButtonLabel", "withLoginLink", "loginLink", "loginLabel"];
216
+ var propTypes$4 = {
216
217
  action: PropTypes.string,
217
218
  fields: PropTypes$1.fields,
218
219
  size: PropTypes.string,
@@ -225,8 +226,9 @@ var propTypes$2 = {
225
226
  loginLink: PropTypes.string,
226
227
  loginLabel: PropTypes$1.label
227
228
  };
228
- var defaultProps$2 = {
229
+ var defaultProps$4 = {
229
230
  action: '/register',
231
+ // https://bold.media.test:8080/register
230
232
  fields: null,
231
233
  size: 'lg',
232
234
  nameLabel: /*#__PURE__*/React.createElement(FormattedMessage, {
@@ -287,7 +289,7 @@ var Register = function Register(_ref) {
287
289
  withLoginLink = _ref.withLoginLink,
288
290
  loginLink = _ref.loginLink,
289
291
  loginLabel = _ref.loginLabel,
290
- props = _objectWithoutProperties(_ref, _excluded$2);
292
+ props = _objectWithoutProperties(_ref, _excluded$4);
291
293
 
292
294
  return /*#__PURE__*/React.createElement(Form, Object.assign({
293
295
  action: action,
@@ -320,11 +322,11 @@ var Register = function Register(_ref) {
320
322
  }, props));
321
323
  };
322
324
 
323
- Register.propTypes = propTypes$2;
324
- Register.defaultProps = defaultProps$2;
325
+ Register.propTypes = propTypes$4;
326
+ Register.defaultProps = defaultProps$4;
325
327
 
326
- var _excluded$1 = ["action", "fields", "size", "passwordLabel", "passwordConfirmationLabel", "submitButtonLabel"];
327
- var propTypes$1 = {
328
+ var _excluded$3 = ["action", "fields", "size", "passwordLabel", "passwordConfirmationLabel", "submitButtonLabel"];
329
+ var propTypes$3 = {
328
330
  action: PropTypes.string,
329
331
  fields: PropTypes$1.fields,
330
332
  size: PropTypes.string,
@@ -332,7 +334,7 @@ var propTypes$1 = {
332
334
  passwordConfirmationLabel: PropTypes$1.label,
333
335
  submitButtonLabel: PropTypes$1.label
334
336
  };
335
- var defaultProps$1 = {
337
+ var defaultProps$3 = {
336
338
  action: '/reset-password',
337
339
  fields: null,
338
340
  size: 'lg',
@@ -366,7 +368,7 @@ var ResetPassword = function ResetPassword(_ref) {
366
368
  passwordLabel = _ref.passwordLabel,
367
369
  passwordConfirmationLabel = _ref.passwordConfirmationLabel,
368
370
  submitButtonLabel = _ref.submitButtonLabel,
369
- props = _objectWithoutProperties(_ref, _excluded$1);
371
+ props = _objectWithoutProperties(_ref, _excluded$3);
370
372
 
371
373
  return /*#__PURE__*/React.createElement(Form, Object.assign({
372
374
  action: action,
@@ -385,8 +387,131 @@ var ResetPassword = function ResetPassword(_ref) {
385
387
  }, props));
386
388
  };
387
389
 
388
- ResetPassword.propTypes = propTypes$1;
389
- ResetPassword.defaultProps = defaultProps$1;
390
+ ResetPassword.propTypes = propTypes$3;
391
+ ResetPassword.defaultProps = defaultProps$3;
392
+
393
+ var _excluded$2 = ["action", "fields", "size", "codeLabel", "submitButtonLabel"];
394
+ var propTypes$2 = {
395
+ action: PropTypes.string,
396
+ fields: PropTypes$1.fields,
397
+ size: PropTypes.string,
398
+ codeLabel: PropTypes$1.label,
399
+ submitButtonLabel: PropTypes$1.label
400
+ };
401
+ var defaultProps$2 = {
402
+ action: '/two-factor-challenge',
403
+ fields: null,
404
+ size: 'lg',
405
+ codeLabel: /*#__PURE__*/React.createElement(FormattedMessage, {
406
+ id: "22Ld5M",
407
+ defaultMessage: [{
408
+ "type": 0,
409
+ "value": "Enter the code from your authenticator app to continue"
410
+ }]
411
+ }),
412
+ submitButtonLabel: /*#__PURE__*/React.createElement(FormattedMessage, {
413
+ id: "QUAHwy",
414
+ defaultMessage: [{
415
+ "type": 0,
416
+ "value": "Continue"
417
+ }]
418
+ })
419
+ };
420
+
421
+ var TwoFactorChallenge = function TwoFactorChallenge(_ref) {
422
+ var action = _ref.action,
423
+ fields = _ref.fields,
424
+ size = _ref.size,
425
+ codeLabel = _ref.codeLabel,
426
+ submitButtonLabel = _ref.submitButtonLabel,
427
+ props = _objectWithoutProperties(_ref, _excluded$2);
428
+
429
+ return /*#__PURE__*/React.createElement(Form, Object.assign({
430
+ action: action,
431
+ fields: fields || [{
432
+ name: 'code',
433
+ type: 'text',
434
+ size: size,
435
+ label: codeLabel
436
+ }],
437
+ submitButtonLabel: submitButtonLabel
438
+ }, props));
439
+ };
440
+
441
+ TwoFactorChallenge.propTypes = propTypes$2;
442
+ TwoFactorChallenge.defaultProps = defaultProps$2;
443
+
444
+ var _excluded$1 = ["action", "fields", "explainationLabel", "submitButtonLabel", "size", "withCancelLink", "cancelLink", "cancelLabel"];
445
+ var propTypes$1 = {
446
+ action: PropTypes.string,
447
+ fields: PropTypes$1.fields,
448
+ size: PropTypes.string,
449
+ explainationLabel: PropTypes$1.label,
450
+ submitButtonLabel: PropTypes$1.label,
451
+ withCancelLink: PropTypes.bool,
452
+ cancelLink: PropTypes.string,
453
+ cancelLabel: PropTypes$1.label
454
+ };
455
+ var defaultProps$1 = {
456
+ action: '/user/two-factor-authentication',
457
+ fields: null,
458
+ size: 'lg',
459
+ explainationLabel: /*#__PURE__*/React.createElement(FormattedMessage, {
460
+ id: "5nHK/H",
461
+ defaultMessage: [{
462
+ "type": 0,
463
+ "value": "Do you really wish to disable two factor authentication on your account?"
464
+ }]
465
+ }),
466
+ submitButtonLabel: /*#__PURE__*/React.createElement(FormattedMessage, {
467
+ id: "gWmL5V",
468
+ defaultMessage: [{
469
+ "type": 0,
470
+ "value": "Disable two factor authentication"
471
+ }]
472
+ }),
473
+ withCancelLink: true,
474
+ cancelLink: '/home',
475
+ cancelLabel: /*#__PURE__*/React.createElement(FormattedMessage, {
476
+ id: "U/ye2x",
477
+ defaultMessage: [{
478
+ "type": 0,
479
+ "value": "Cancel"
480
+ }]
481
+ })
482
+ };
483
+
484
+ var TwoFactorDisable = function TwoFactorDisable(_ref) {
485
+ var action = _ref.action;
486
+ _ref.fields;
487
+ var explainationLabel = _ref.explainationLabel,
488
+ submitButtonLabel = _ref.submitButtonLabel;
489
+ _ref.size;
490
+ var withCancelLink = _ref.withCancelLink,
491
+ cancelLink = _ref.cancelLink,
492
+ cancelLabel = _ref.cancelLabel,
493
+ props = _objectWithoutProperties(_ref, _excluded$1);
494
+
495
+ var defaultPostForm = useCallback(function (act, data) {
496
+ return postJSON(act, data, {
497
+ credentials: 'include',
498
+ headers: getCSRFHeaders(),
499
+ method: 'DELETE'
500
+ });
501
+ }, []);
502
+ return /*#__PURE__*/React.createElement(Form, Object.assign({
503
+ action: action,
504
+ submitButtonLabel: submitButtonLabel,
505
+ actions: withCancelLink ? /*#__PURE__*/React.createElement(Link, {
506
+ className: "py-2 px-4",
507
+ to: cancelLink
508
+ }, cancelLabel) : null,
509
+ postForm: defaultPostForm
510
+ }, props), /*#__PURE__*/React.createElement("p", null, explainationLabel));
511
+ };
512
+
513
+ TwoFactorDisable.propTypes = propTypes$1;
514
+ TwoFactorDisable.defaultProps = defaultProps$1;
390
515
 
391
516
  var _excluded = ["action", "fields", "explainationLabel", "submitButtonLabel", "size", "withSkipLink", "skipLink", "skipLabel"];
392
517
  var propTypes = {
@@ -411,10 +536,10 @@ var defaultProps = {
411
536
  }]
412
537
  }),
413
538
  submitButtonLabel: /*#__PURE__*/React.createElement(FormattedMessage, {
414
- id: "gj67c0",
539
+ id: "pVHYDd",
415
540
  defaultMessage: [{
416
541
  "type": 0,
417
- "value": "Enable Two Factor authentication"
542
+ "value": "Enable two factor authentication"
418
543
  }]
419
544
  }),
420
545
  withSkipLink: true,
@@ -428,7 +553,7 @@ var defaultProps = {
428
553
  })
429
554
  };
430
555
 
431
- var TwoFactor = function TwoFactor(_ref) {
556
+ var TwoFactorEnable = function TwoFactorEnable(_ref) {
432
557
  var action = _ref.action;
433
558
  _ref.fields;
434
559
  var explainationLabel = _ref.explainationLabel,
@@ -449,7 +574,7 @@ var TwoFactor = function TwoFactor(_ref) {
449
574
  }, props), /*#__PURE__*/React.createElement("p", null, explainationLabel));
450
575
  };
451
576
 
452
- TwoFactor.propTypes = propTypes;
453
- TwoFactor.defaultProps = defaultProps;
577
+ TwoFactorEnable.propTypes = propTypes;
578
+ TwoFactorEnable.defaultProps = defaultProps;
454
579
 
455
- export { ConfirmPassword, ForgotPassword, Login, Register, ResetPassword, TwoFactor };
580
+ export { ConfirmPassword, ForgotPassword, Login, Register, ResetPassword, TwoFactorChallenge, TwoFactorDisable, TwoFactorEnable };
package/lib/index.js CHANGED
@@ -9,6 +9,7 @@ var PropTypes = require('prop-types');
9
9
  var React = require('react');
10
10
  var reactIntl = require('react-intl');
11
11
  var reactRouterDom = require('react-router-dom');
12
+ var fetch = require('@folklore/fetch');
12
13
 
13
14
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
14
15
 
@@ -17,15 +18,15 @@ var Form__default = /*#__PURE__*/_interopDefaultLegacy(Form);
17
18
  var PropTypes__default = /*#__PURE__*/_interopDefaultLegacy(PropTypes);
18
19
  var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
19
20
 
20
- var _excluded$5 = ["action", "fields", "size", "passwordLabel", "submitButtonLabel"];
21
- var propTypes$5 = {
21
+ var _excluded$7 = ["action", "fields", "size", "passwordLabel", "submitButtonLabel"];
22
+ var propTypes$7 = {
22
23
  action: PropTypes__default["default"].string,
23
24
  fields: core.PropTypes.fields,
24
25
  size: PropTypes__default["default"].string,
25
26
  passwordLabel: core.PropTypes.label,
26
27
  submitButtonLabel: core.PropTypes.label
27
28
  };
28
- var defaultProps$5 = {
29
+ var defaultProps$7 = {
29
30
  action: '/user/confirm-password',
30
31
  fields: null,
31
32
  size: 'lg',
@@ -37,10 +38,10 @@ var defaultProps$5 = {
37
38
  }]
38
39
  }),
39
40
  submitButtonLabel: /*#__PURE__*/React__default["default"].createElement(reactIntl.FormattedMessage, {
40
- id: "RRwdkV",
41
+ id: "QUAHwy",
41
42
  defaultMessage: [{
42
43
  "type": 0,
43
- "value": "Contnue"
44
+ "value": "Continue"
44
45
  }]
45
46
  })
46
47
  };
@@ -51,7 +52,7 @@ var ConfirmPassword = function ConfirmPassword(_ref) {
51
52
  size = _ref.size,
52
53
  passwordLabel = _ref.passwordLabel,
53
54
  submitButtonLabel = _ref.submitButtonLabel,
54
- props = _objectWithoutProperties__default["default"](_ref, _excluded$5);
55
+ props = _objectWithoutProperties__default["default"](_ref, _excluded$7);
55
56
 
56
57
  return /*#__PURE__*/React__default["default"].createElement(Form__default["default"], Object.assign({
57
58
  action: action,
@@ -65,11 +66,11 @@ var ConfirmPassword = function ConfirmPassword(_ref) {
65
66
  }, props));
66
67
  };
67
68
 
68
- ConfirmPassword.propTypes = propTypes$5;
69
- ConfirmPassword.defaultProps = defaultProps$5;
69
+ ConfirmPassword.propTypes = propTypes$7;
70
+ ConfirmPassword.defaultProps = defaultProps$7;
70
71
 
71
- var _excluded$4 = ["action", "fields", "emailLabel", "submitButtonLabel", "size", "withLoginLink", "loginLink", "loginLabel"];
72
- var propTypes$4 = {
72
+ var _excluded$6 = ["action", "fields", "emailLabel", "submitButtonLabel", "size", "withLoginLink", "loginLink", "loginLabel"];
73
+ var propTypes$6 = {
73
74
  action: PropTypes__default["default"].string,
74
75
  fields: core.PropTypes.fields,
75
76
  size: PropTypes__default["default"].string,
@@ -79,7 +80,7 @@ var propTypes$4 = {
79
80
  loginLink: PropTypes__default["default"].string,
80
81
  loginLabel: core.PropTypes.label
81
82
  };
82
- var defaultProps$4 = {
83
+ var defaultProps$6 = {
83
84
  action: '/forgot-password',
84
85
  fields: null,
85
86
  size: 'lg',
@@ -117,7 +118,7 @@ var ForgotPassword = function ForgotPassword(_ref) {
117
118
  withLoginLink = _ref.withLoginLink,
118
119
  loginLink = _ref.loginLink,
119
120
  loginLabel = _ref.loginLabel,
120
- props = _objectWithoutProperties__default["default"](_ref, _excluded$4);
121
+ props = _objectWithoutProperties__default["default"](_ref, _excluded$6);
121
122
 
122
123
  return /*#__PURE__*/React__default["default"].createElement(Form__default["default"], Object.assign({
123
124
  action: action,
@@ -135,11 +136,11 @@ var ForgotPassword = function ForgotPassword(_ref) {
135
136
  }, props));
136
137
  };
137
138
 
138
- ForgotPassword.propTypes = propTypes$4;
139
- ForgotPassword.defaultProps = defaultProps$4;
139
+ ForgotPassword.propTypes = propTypes$6;
140
+ ForgotPassword.defaultProps = defaultProps$6;
140
141
 
141
- var _excluded$3 = ["action", "fields", "size", "emailLabel", "passwordLabel", "submitButtonLabel", "withForgotPassword", "forgotPasswordLink", "forgotPasswordLabel"];
142
- var propTypes$3 = {
142
+ var _excluded$5 = ["action", "fields", "size", "emailLabel", "passwordLabel", "submitButtonLabel", "withForgotPassword", "forgotPasswordLink", "forgotPasswordLabel"];
143
+ var propTypes$5 = {
143
144
  action: PropTypes__default["default"].string,
144
145
  fields: core.PropTypes.fields,
145
146
  size: PropTypes__default["default"].string,
@@ -150,7 +151,7 @@ var propTypes$3 = {
150
151
  forgotPasswordLink: PropTypes__default["default"].string,
151
152
  forgotPasswordLabel: core.PropTypes.label
152
153
  };
153
- var defaultProps$3 = {
154
+ var defaultProps$5 = {
154
155
  action: '/login',
155
156
  fields: null,
156
157
  size: 'lg',
@@ -196,7 +197,7 @@ var Login = function Login(_ref) {
196
197
  withForgotPassword = _ref.withForgotPassword,
197
198
  forgotPasswordLink = _ref.forgotPasswordLink,
198
199
  forgotPasswordLabel = _ref.forgotPasswordLabel,
199
- props = _objectWithoutProperties__default["default"](_ref, _excluded$3);
200
+ props = _objectWithoutProperties__default["default"](_ref, _excluded$5);
200
201
 
201
202
  return /*#__PURE__*/React__default["default"].createElement(Form__default["default"], Object.assign({
202
203
  action: action,
@@ -219,11 +220,11 @@ var Login = function Login(_ref) {
219
220
  }, props));
220
221
  };
221
222
 
222
- Login.propTypes = propTypes$3;
223
- Login.defaultProps = defaultProps$3;
223
+ Login.propTypes = propTypes$5;
224
+ Login.defaultProps = defaultProps$5;
224
225
 
225
- var _excluded$2 = ["action", "fields", "size", "nameLabel", "emailLabel", "passwordLabel", "passwordConfirmationLabel", "submitButtonLabel", "withLoginLink", "loginLink", "loginLabel"];
226
- var propTypes$2 = {
226
+ var _excluded$4 = ["action", "fields", "size", "nameLabel", "emailLabel", "passwordLabel", "passwordConfirmationLabel", "submitButtonLabel", "withLoginLink", "loginLink", "loginLabel"];
227
+ var propTypes$4 = {
227
228
  action: PropTypes__default["default"].string,
228
229
  fields: core.PropTypes.fields,
229
230
  size: PropTypes__default["default"].string,
@@ -236,8 +237,9 @@ var propTypes$2 = {
236
237
  loginLink: PropTypes__default["default"].string,
237
238
  loginLabel: core.PropTypes.label
238
239
  };
239
- var defaultProps$2 = {
240
+ var defaultProps$4 = {
240
241
  action: '/register',
242
+ // https://bold.media.test:8080/register
241
243
  fields: null,
242
244
  size: 'lg',
243
245
  nameLabel: /*#__PURE__*/React__default["default"].createElement(reactIntl.FormattedMessage, {
@@ -298,7 +300,7 @@ var Register = function Register(_ref) {
298
300
  withLoginLink = _ref.withLoginLink,
299
301
  loginLink = _ref.loginLink,
300
302
  loginLabel = _ref.loginLabel,
301
- props = _objectWithoutProperties__default["default"](_ref, _excluded$2);
303
+ props = _objectWithoutProperties__default["default"](_ref, _excluded$4);
302
304
 
303
305
  return /*#__PURE__*/React__default["default"].createElement(Form__default["default"], Object.assign({
304
306
  action: action,
@@ -331,11 +333,11 @@ var Register = function Register(_ref) {
331
333
  }, props));
332
334
  };
333
335
 
334
- Register.propTypes = propTypes$2;
335
- Register.defaultProps = defaultProps$2;
336
+ Register.propTypes = propTypes$4;
337
+ Register.defaultProps = defaultProps$4;
336
338
 
337
- var _excluded$1 = ["action", "fields", "size", "passwordLabel", "passwordConfirmationLabel", "submitButtonLabel"];
338
- var propTypes$1 = {
339
+ var _excluded$3 = ["action", "fields", "size", "passwordLabel", "passwordConfirmationLabel", "submitButtonLabel"];
340
+ var propTypes$3 = {
339
341
  action: PropTypes__default["default"].string,
340
342
  fields: core.PropTypes.fields,
341
343
  size: PropTypes__default["default"].string,
@@ -343,7 +345,7 @@ var propTypes$1 = {
343
345
  passwordConfirmationLabel: core.PropTypes.label,
344
346
  submitButtonLabel: core.PropTypes.label
345
347
  };
346
- var defaultProps$1 = {
348
+ var defaultProps$3 = {
347
349
  action: '/reset-password',
348
350
  fields: null,
349
351
  size: 'lg',
@@ -377,7 +379,7 @@ var ResetPassword = function ResetPassword(_ref) {
377
379
  passwordLabel = _ref.passwordLabel,
378
380
  passwordConfirmationLabel = _ref.passwordConfirmationLabel,
379
381
  submitButtonLabel = _ref.submitButtonLabel,
380
- props = _objectWithoutProperties__default["default"](_ref, _excluded$1);
382
+ props = _objectWithoutProperties__default["default"](_ref, _excluded$3);
381
383
 
382
384
  return /*#__PURE__*/React__default["default"].createElement(Form__default["default"], Object.assign({
383
385
  action: action,
@@ -396,8 +398,131 @@ var ResetPassword = function ResetPassword(_ref) {
396
398
  }, props));
397
399
  };
398
400
 
399
- ResetPassword.propTypes = propTypes$1;
400
- ResetPassword.defaultProps = defaultProps$1;
401
+ ResetPassword.propTypes = propTypes$3;
402
+ ResetPassword.defaultProps = defaultProps$3;
403
+
404
+ var _excluded$2 = ["action", "fields", "size", "codeLabel", "submitButtonLabel"];
405
+ var propTypes$2 = {
406
+ action: PropTypes__default["default"].string,
407
+ fields: core.PropTypes.fields,
408
+ size: PropTypes__default["default"].string,
409
+ codeLabel: core.PropTypes.label,
410
+ submitButtonLabel: core.PropTypes.label
411
+ };
412
+ var defaultProps$2 = {
413
+ action: '/two-factor-challenge',
414
+ fields: null,
415
+ size: 'lg',
416
+ codeLabel: /*#__PURE__*/React__default["default"].createElement(reactIntl.FormattedMessage, {
417
+ id: "22Ld5M",
418
+ defaultMessage: [{
419
+ "type": 0,
420
+ "value": "Enter the code from your authenticator app to continue"
421
+ }]
422
+ }),
423
+ submitButtonLabel: /*#__PURE__*/React__default["default"].createElement(reactIntl.FormattedMessage, {
424
+ id: "QUAHwy",
425
+ defaultMessage: [{
426
+ "type": 0,
427
+ "value": "Continue"
428
+ }]
429
+ })
430
+ };
431
+
432
+ var TwoFactorChallenge = function TwoFactorChallenge(_ref) {
433
+ var action = _ref.action,
434
+ fields = _ref.fields,
435
+ size = _ref.size,
436
+ codeLabel = _ref.codeLabel,
437
+ submitButtonLabel = _ref.submitButtonLabel,
438
+ props = _objectWithoutProperties__default["default"](_ref, _excluded$2);
439
+
440
+ return /*#__PURE__*/React__default["default"].createElement(Form__default["default"], Object.assign({
441
+ action: action,
442
+ fields: fields || [{
443
+ name: 'code',
444
+ type: 'text',
445
+ size: size,
446
+ label: codeLabel
447
+ }],
448
+ submitButtonLabel: submitButtonLabel
449
+ }, props));
450
+ };
451
+
452
+ TwoFactorChallenge.propTypes = propTypes$2;
453
+ TwoFactorChallenge.defaultProps = defaultProps$2;
454
+
455
+ var _excluded$1 = ["action", "fields", "explainationLabel", "submitButtonLabel", "size", "withCancelLink", "cancelLink", "cancelLabel"];
456
+ var propTypes$1 = {
457
+ action: PropTypes__default["default"].string,
458
+ fields: core.PropTypes.fields,
459
+ size: PropTypes__default["default"].string,
460
+ explainationLabel: core.PropTypes.label,
461
+ submitButtonLabel: core.PropTypes.label,
462
+ withCancelLink: PropTypes__default["default"].bool,
463
+ cancelLink: PropTypes__default["default"].string,
464
+ cancelLabel: core.PropTypes.label
465
+ };
466
+ var defaultProps$1 = {
467
+ action: '/user/two-factor-authentication',
468
+ fields: null,
469
+ size: 'lg',
470
+ explainationLabel: /*#__PURE__*/React__default["default"].createElement(reactIntl.FormattedMessage, {
471
+ id: "5nHK/H",
472
+ defaultMessage: [{
473
+ "type": 0,
474
+ "value": "Do you really wish to disable two factor authentication on your account?"
475
+ }]
476
+ }),
477
+ submitButtonLabel: /*#__PURE__*/React__default["default"].createElement(reactIntl.FormattedMessage, {
478
+ id: "gWmL5V",
479
+ defaultMessage: [{
480
+ "type": 0,
481
+ "value": "Disable two factor authentication"
482
+ }]
483
+ }),
484
+ withCancelLink: true,
485
+ cancelLink: '/home',
486
+ cancelLabel: /*#__PURE__*/React__default["default"].createElement(reactIntl.FormattedMessage, {
487
+ id: "U/ye2x",
488
+ defaultMessage: [{
489
+ "type": 0,
490
+ "value": "Cancel"
491
+ }]
492
+ })
493
+ };
494
+
495
+ var TwoFactorDisable = function TwoFactorDisable(_ref) {
496
+ var action = _ref.action;
497
+ _ref.fields;
498
+ var explainationLabel = _ref.explainationLabel,
499
+ submitButtonLabel = _ref.submitButtonLabel;
500
+ _ref.size;
501
+ var withCancelLink = _ref.withCancelLink,
502
+ cancelLink = _ref.cancelLink,
503
+ cancelLabel = _ref.cancelLabel,
504
+ props = _objectWithoutProperties__default["default"](_ref, _excluded$1);
505
+
506
+ var defaultPostForm = React.useCallback(function (act, data) {
507
+ return fetch.postJSON(act, data, {
508
+ credentials: 'include',
509
+ headers: fetch.getCSRFHeaders(),
510
+ method: 'DELETE'
511
+ });
512
+ }, []);
513
+ return /*#__PURE__*/React__default["default"].createElement(Form__default["default"], Object.assign({
514
+ action: action,
515
+ submitButtonLabel: submitButtonLabel,
516
+ actions: withCancelLink ? /*#__PURE__*/React__default["default"].createElement(reactRouterDom.Link, {
517
+ className: "py-2 px-4",
518
+ to: cancelLink
519
+ }, cancelLabel) : null,
520
+ postForm: defaultPostForm
521
+ }, props), /*#__PURE__*/React__default["default"].createElement("p", null, explainationLabel));
522
+ };
523
+
524
+ TwoFactorDisable.propTypes = propTypes$1;
525
+ TwoFactorDisable.defaultProps = defaultProps$1;
401
526
 
402
527
  var _excluded = ["action", "fields", "explainationLabel", "submitButtonLabel", "size", "withSkipLink", "skipLink", "skipLabel"];
403
528
  var propTypes = {
@@ -422,10 +547,10 @@ var defaultProps = {
422
547
  }]
423
548
  }),
424
549
  submitButtonLabel: /*#__PURE__*/React__default["default"].createElement(reactIntl.FormattedMessage, {
425
- id: "gj67c0",
550
+ id: "pVHYDd",
426
551
  defaultMessage: [{
427
552
  "type": 0,
428
- "value": "Enable Two Factor authentication"
553
+ "value": "Enable two factor authentication"
429
554
  }]
430
555
  }),
431
556
  withSkipLink: true,
@@ -439,7 +564,7 @@ var defaultProps = {
439
564
  })
440
565
  };
441
566
 
442
- var TwoFactor = function TwoFactor(_ref) {
567
+ var TwoFactorEnable = function TwoFactorEnable(_ref) {
443
568
  var action = _ref.action;
444
569
  _ref.fields;
445
570
  var explainationLabel = _ref.explainationLabel,
@@ -460,12 +585,14 @@ var TwoFactor = function TwoFactor(_ref) {
460
585
  }, props), /*#__PURE__*/React__default["default"].createElement("p", null, explainationLabel));
461
586
  };
462
587
 
463
- TwoFactor.propTypes = propTypes;
464
- TwoFactor.defaultProps = defaultProps;
588
+ TwoFactorEnable.propTypes = propTypes;
589
+ TwoFactorEnable.defaultProps = defaultProps;
465
590
 
466
591
  exports.ConfirmPassword = ConfirmPassword;
467
592
  exports.ForgotPassword = ForgotPassword;
468
593
  exports.Login = Login;
469
594
  exports.Register = Register;
470
595
  exports.ResetPassword = ResetPassword;
471
- exports.TwoFactor = TwoFactor;
596
+ exports.TwoFactorChallenge = TwoFactorChallenge;
597
+ exports.TwoFactorDisable = TwoFactorDisable;
598
+ exports.TwoFactorEnable = TwoFactorEnable;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@panneau/form-auth",
3
- "version": "1.0.0-alpha.242",
3
+ "version": "1.0.0-alpha.243",
4
4
  "description": "Basic forgot password form",
5
5
  "keywords": [
6
6
  "javascript"
@@ -46,6 +46,7 @@
46
46
  },
47
47
  "dependencies": {
48
48
  "@babel/runtime": "^7.12.5",
49
+ "@folklore/fetch": "^0.1.15",
49
50
  "@panneau/core": "^1.0.0-alpha.242",
50
51
  "@panneau/form": "^1.0.0-alpha.242",
51
52
  "classnames": "^2.2.6",
@@ -57,5 +58,5 @@
57
58
  "publishConfig": {
58
59
  "access": "public"
59
60
  },
60
- "gitHead": "642186399b25e090f6fa3a210d14f195e2121a38"
61
+ "gitHead": "9703e84a7d27cfc0024e95e7f82da20d1637079a"
61
62
  }