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

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 +163 -39
  2. package/lib/index.js +164 -38
  3. package/package.json +5 -4
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,7 +226,7 @@ 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',
230
231
  fields: null,
231
232
  size: 'lg',
@@ -287,7 +288,7 @@ var Register = function Register(_ref) {
287
288
  withLoginLink = _ref.withLoginLink,
288
289
  loginLink = _ref.loginLink,
289
290
  loginLabel = _ref.loginLabel,
290
- props = _objectWithoutProperties(_ref, _excluded$2);
291
+ props = _objectWithoutProperties(_ref, _excluded$4);
291
292
 
292
293
  return /*#__PURE__*/React.createElement(Form, Object.assign({
293
294
  action: action,
@@ -320,11 +321,11 @@ var Register = function Register(_ref) {
320
321
  }, props));
321
322
  };
322
323
 
323
- Register.propTypes = propTypes$2;
324
- Register.defaultProps = defaultProps$2;
324
+ Register.propTypes = propTypes$4;
325
+ Register.defaultProps = defaultProps$4;
325
326
 
326
- var _excluded$1 = ["action", "fields", "size", "passwordLabel", "passwordConfirmationLabel", "submitButtonLabel"];
327
- var propTypes$1 = {
327
+ var _excluded$3 = ["action", "fields", "size", "passwordLabel", "passwordConfirmationLabel", "submitButtonLabel"];
328
+ var propTypes$3 = {
328
329
  action: PropTypes.string,
329
330
  fields: PropTypes$1.fields,
330
331
  size: PropTypes.string,
@@ -332,7 +333,7 @@ var propTypes$1 = {
332
333
  passwordConfirmationLabel: PropTypes$1.label,
333
334
  submitButtonLabel: PropTypes$1.label
334
335
  };
335
- var defaultProps$1 = {
336
+ var defaultProps$3 = {
336
337
  action: '/reset-password',
337
338
  fields: null,
338
339
  size: 'lg',
@@ -366,7 +367,7 @@ var ResetPassword = function ResetPassword(_ref) {
366
367
  passwordLabel = _ref.passwordLabel,
367
368
  passwordConfirmationLabel = _ref.passwordConfirmationLabel,
368
369
  submitButtonLabel = _ref.submitButtonLabel,
369
- props = _objectWithoutProperties(_ref, _excluded$1);
370
+ props = _objectWithoutProperties(_ref, _excluded$3);
370
371
 
371
372
  return /*#__PURE__*/React.createElement(Form, Object.assign({
372
373
  action: action,
@@ -385,8 +386,131 @@ var ResetPassword = function ResetPassword(_ref) {
385
386
  }, props));
386
387
  };
387
388
 
388
- ResetPassword.propTypes = propTypes$1;
389
- ResetPassword.defaultProps = defaultProps$1;
389
+ ResetPassword.propTypes = propTypes$3;
390
+ ResetPassword.defaultProps = defaultProps$3;
391
+
392
+ var _excluded$2 = ["action", "fields", "size", "codeLabel", "submitButtonLabel"];
393
+ var propTypes$2 = {
394
+ action: PropTypes.string,
395
+ fields: PropTypes$1.fields,
396
+ size: PropTypes.string,
397
+ codeLabel: PropTypes$1.label,
398
+ submitButtonLabel: PropTypes$1.label
399
+ };
400
+ var defaultProps$2 = {
401
+ action: '/two-factor-challenge',
402
+ fields: null,
403
+ size: 'lg',
404
+ codeLabel: /*#__PURE__*/React.createElement(FormattedMessage, {
405
+ id: "22Ld5M",
406
+ defaultMessage: [{
407
+ "type": 0,
408
+ "value": "Enter the code from your authenticator app to continue"
409
+ }]
410
+ }),
411
+ submitButtonLabel: /*#__PURE__*/React.createElement(FormattedMessage, {
412
+ id: "QUAHwy",
413
+ defaultMessage: [{
414
+ "type": 0,
415
+ "value": "Continue"
416
+ }]
417
+ })
418
+ };
419
+
420
+ var TwoFactorChallenge = function TwoFactorChallenge(_ref) {
421
+ var action = _ref.action,
422
+ fields = _ref.fields,
423
+ size = _ref.size,
424
+ codeLabel = _ref.codeLabel,
425
+ submitButtonLabel = _ref.submitButtonLabel,
426
+ props = _objectWithoutProperties(_ref, _excluded$2);
427
+
428
+ return /*#__PURE__*/React.createElement(Form, Object.assign({
429
+ action: action,
430
+ fields: fields || [{
431
+ name: 'code',
432
+ type: 'text',
433
+ size: size,
434
+ label: codeLabel
435
+ }],
436
+ submitButtonLabel: submitButtonLabel
437
+ }, props));
438
+ };
439
+
440
+ TwoFactorChallenge.propTypes = propTypes$2;
441
+ TwoFactorChallenge.defaultProps = defaultProps$2;
442
+
443
+ var _excluded$1 = ["action", "fields", "explainationLabel", "submitButtonLabel", "size", "withCancelLink", "cancelLink", "cancelLabel"];
444
+ var propTypes$1 = {
445
+ action: PropTypes.string,
446
+ fields: PropTypes$1.fields,
447
+ size: PropTypes.string,
448
+ explainationLabel: PropTypes$1.label,
449
+ submitButtonLabel: PropTypes$1.label,
450
+ withCancelLink: PropTypes.bool,
451
+ cancelLink: PropTypes.string,
452
+ cancelLabel: PropTypes$1.label
453
+ };
454
+ var defaultProps$1 = {
455
+ action: '/user/two-factor-authentication',
456
+ fields: null,
457
+ size: 'lg',
458
+ explainationLabel: /*#__PURE__*/React.createElement(FormattedMessage, {
459
+ id: "5nHK/H",
460
+ defaultMessage: [{
461
+ "type": 0,
462
+ "value": "Do you really wish to disable two factor authentication on your account?"
463
+ }]
464
+ }),
465
+ submitButtonLabel: /*#__PURE__*/React.createElement(FormattedMessage, {
466
+ id: "gWmL5V",
467
+ defaultMessage: [{
468
+ "type": 0,
469
+ "value": "Disable two factor authentication"
470
+ }]
471
+ }),
472
+ withCancelLink: true,
473
+ cancelLink: '/home',
474
+ cancelLabel: /*#__PURE__*/React.createElement(FormattedMessage, {
475
+ id: "U/ye2x",
476
+ defaultMessage: [{
477
+ "type": 0,
478
+ "value": "Cancel"
479
+ }]
480
+ })
481
+ };
482
+
483
+ var TwoFactorDisable = function TwoFactorDisable(_ref) {
484
+ var action = _ref.action;
485
+ _ref.fields;
486
+ var explainationLabel = _ref.explainationLabel,
487
+ submitButtonLabel = _ref.submitButtonLabel;
488
+ _ref.size;
489
+ var withCancelLink = _ref.withCancelLink,
490
+ cancelLink = _ref.cancelLink,
491
+ cancelLabel = _ref.cancelLabel,
492
+ props = _objectWithoutProperties(_ref, _excluded$1);
493
+
494
+ var defaultPostForm = useCallback(function (act, data) {
495
+ return postJSON(act, data, {
496
+ credentials: 'include',
497
+ headers: getCSRFHeaders(),
498
+ method: 'DELETE'
499
+ });
500
+ }, []);
501
+ return /*#__PURE__*/React.createElement(Form, Object.assign({
502
+ action: action,
503
+ submitButtonLabel: submitButtonLabel,
504
+ actions: withCancelLink ? /*#__PURE__*/React.createElement(Link, {
505
+ className: "py-2 px-4",
506
+ to: cancelLink
507
+ }, cancelLabel) : null,
508
+ postForm: defaultPostForm
509
+ }, props), /*#__PURE__*/React.createElement("p", null, explainationLabel));
510
+ };
511
+
512
+ TwoFactorDisable.propTypes = propTypes$1;
513
+ TwoFactorDisable.defaultProps = defaultProps$1;
390
514
 
391
515
  var _excluded = ["action", "fields", "explainationLabel", "submitButtonLabel", "size", "withSkipLink", "skipLink", "skipLabel"];
392
516
  var propTypes = {
@@ -411,10 +535,10 @@ var defaultProps = {
411
535
  }]
412
536
  }),
413
537
  submitButtonLabel: /*#__PURE__*/React.createElement(FormattedMessage, {
414
- id: "gj67c0",
538
+ id: "pVHYDd",
415
539
  defaultMessage: [{
416
540
  "type": 0,
417
- "value": "Enable Two Factor authentication"
541
+ "value": "Enable two factor authentication"
418
542
  }]
419
543
  }),
420
544
  withSkipLink: true,
@@ -428,7 +552,7 @@ var defaultProps = {
428
552
  })
429
553
  };
430
554
 
431
- var TwoFactor = function TwoFactor(_ref) {
555
+ var TwoFactorEnable = function TwoFactorEnable(_ref) {
432
556
  var action = _ref.action;
433
557
  _ref.fields;
434
558
  var explainationLabel = _ref.explainationLabel,
@@ -449,7 +573,7 @@ var TwoFactor = function TwoFactor(_ref) {
449
573
  }, props), /*#__PURE__*/React.createElement("p", null, explainationLabel));
450
574
  };
451
575
 
452
- TwoFactor.propTypes = propTypes;
453
- TwoFactor.defaultProps = defaultProps;
576
+ TwoFactorEnable.propTypes = propTypes;
577
+ TwoFactorEnable.defaultProps = defaultProps;
454
578
 
455
- export { ConfirmPassword, ForgotPassword, Login, Register, ResetPassword, TwoFactor };
579
+ 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,7 +237,7 @@ 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',
241
242
  fields: null,
242
243
  size: 'lg',
@@ -298,7 +299,7 @@ var Register = function Register(_ref) {
298
299
  withLoginLink = _ref.withLoginLink,
299
300
  loginLink = _ref.loginLink,
300
301
  loginLabel = _ref.loginLabel,
301
- props = _objectWithoutProperties__default["default"](_ref, _excluded$2);
302
+ props = _objectWithoutProperties__default["default"](_ref, _excluded$4);
302
303
 
303
304
  return /*#__PURE__*/React__default["default"].createElement(Form__default["default"], Object.assign({
304
305
  action: action,
@@ -331,11 +332,11 @@ var Register = function Register(_ref) {
331
332
  }, props));
332
333
  };
333
334
 
334
- Register.propTypes = propTypes$2;
335
- Register.defaultProps = defaultProps$2;
335
+ Register.propTypes = propTypes$4;
336
+ Register.defaultProps = defaultProps$4;
336
337
 
337
- var _excluded$1 = ["action", "fields", "size", "passwordLabel", "passwordConfirmationLabel", "submitButtonLabel"];
338
- var propTypes$1 = {
338
+ var _excluded$3 = ["action", "fields", "size", "passwordLabel", "passwordConfirmationLabel", "submitButtonLabel"];
339
+ var propTypes$3 = {
339
340
  action: PropTypes__default["default"].string,
340
341
  fields: core.PropTypes.fields,
341
342
  size: PropTypes__default["default"].string,
@@ -343,7 +344,7 @@ var propTypes$1 = {
343
344
  passwordConfirmationLabel: core.PropTypes.label,
344
345
  submitButtonLabel: core.PropTypes.label
345
346
  };
346
- var defaultProps$1 = {
347
+ var defaultProps$3 = {
347
348
  action: '/reset-password',
348
349
  fields: null,
349
350
  size: 'lg',
@@ -377,7 +378,7 @@ var ResetPassword = function ResetPassword(_ref) {
377
378
  passwordLabel = _ref.passwordLabel,
378
379
  passwordConfirmationLabel = _ref.passwordConfirmationLabel,
379
380
  submitButtonLabel = _ref.submitButtonLabel,
380
- props = _objectWithoutProperties__default["default"](_ref, _excluded$1);
381
+ props = _objectWithoutProperties__default["default"](_ref, _excluded$3);
381
382
 
382
383
  return /*#__PURE__*/React__default["default"].createElement(Form__default["default"], Object.assign({
383
384
  action: action,
@@ -396,8 +397,131 @@ var ResetPassword = function ResetPassword(_ref) {
396
397
  }, props));
397
398
  };
398
399
 
399
- ResetPassword.propTypes = propTypes$1;
400
- ResetPassword.defaultProps = defaultProps$1;
400
+ ResetPassword.propTypes = propTypes$3;
401
+ ResetPassword.defaultProps = defaultProps$3;
402
+
403
+ var _excluded$2 = ["action", "fields", "size", "codeLabel", "submitButtonLabel"];
404
+ var propTypes$2 = {
405
+ action: PropTypes__default["default"].string,
406
+ fields: core.PropTypes.fields,
407
+ size: PropTypes__default["default"].string,
408
+ codeLabel: core.PropTypes.label,
409
+ submitButtonLabel: core.PropTypes.label
410
+ };
411
+ var defaultProps$2 = {
412
+ action: '/two-factor-challenge',
413
+ fields: null,
414
+ size: 'lg',
415
+ codeLabel: /*#__PURE__*/React__default["default"].createElement(reactIntl.FormattedMessage, {
416
+ id: "22Ld5M",
417
+ defaultMessage: [{
418
+ "type": 0,
419
+ "value": "Enter the code from your authenticator app to continue"
420
+ }]
421
+ }),
422
+ submitButtonLabel: /*#__PURE__*/React__default["default"].createElement(reactIntl.FormattedMessage, {
423
+ id: "QUAHwy",
424
+ defaultMessage: [{
425
+ "type": 0,
426
+ "value": "Continue"
427
+ }]
428
+ })
429
+ };
430
+
431
+ var TwoFactorChallenge = function TwoFactorChallenge(_ref) {
432
+ var action = _ref.action,
433
+ fields = _ref.fields,
434
+ size = _ref.size,
435
+ codeLabel = _ref.codeLabel,
436
+ submitButtonLabel = _ref.submitButtonLabel,
437
+ props = _objectWithoutProperties__default["default"](_ref, _excluded$2);
438
+
439
+ return /*#__PURE__*/React__default["default"].createElement(Form__default["default"], Object.assign({
440
+ action: action,
441
+ fields: fields || [{
442
+ name: 'code',
443
+ type: 'text',
444
+ size: size,
445
+ label: codeLabel
446
+ }],
447
+ submitButtonLabel: submitButtonLabel
448
+ }, props));
449
+ };
450
+
451
+ TwoFactorChallenge.propTypes = propTypes$2;
452
+ TwoFactorChallenge.defaultProps = defaultProps$2;
453
+
454
+ var _excluded$1 = ["action", "fields", "explainationLabel", "submitButtonLabel", "size", "withCancelLink", "cancelLink", "cancelLabel"];
455
+ var propTypes$1 = {
456
+ action: PropTypes__default["default"].string,
457
+ fields: core.PropTypes.fields,
458
+ size: PropTypes__default["default"].string,
459
+ explainationLabel: core.PropTypes.label,
460
+ submitButtonLabel: core.PropTypes.label,
461
+ withCancelLink: PropTypes__default["default"].bool,
462
+ cancelLink: PropTypes__default["default"].string,
463
+ cancelLabel: core.PropTypes.label
464
+ };
465
+ var defaultProps$1 = {
466
+ action: '/user/two-factor-authentication',
467
+ fields: null,
468
+ size: 'lg',
469
+ explainationLabel: /*#__PURE__*/React__default["default"].createElement(reactIntl.FormattedMessage, {
470
+ id: "5nHK/H",
471
+ defaultMessage: [{
472
+ "type": 0,
473
+ "value": "Do you really wish to disable two factor authentication on your account?"
474
+ }]
475
+ }),
476
+ submitButtonLabel: /*#__PURE__*/React__default["default"].createElement(reactIntl.FormattedMessage, {
477
+ id: "gWmL5V",
478
+ defaultMessage: [{
479
+ "type": 0,
480
+ "value": "Disable two factor authentication"
481
+ }]
482
+ }),
483
+ withCancelLink: true,
484
+ cancelLink: '/home',
485
+ cancelLabel: /*#__PURE__*/React__default["default"].createElement(reactIntl.FormattedMessage, {
486
+ id: "U/ye2x",
487
+ defaultMessage: [{
488
+ "type": 0,
489
+ "value": "Cancel"
490
+ }]
491
+ })
492
+ };
493
+
494
+ var TwoFactorDisable = function TwoFactorDisable(_ref) {
495
+ var action = _ref.action;
496
+ _ref.fields;
497
+ var explainationLabel = _ref.explainationLabel,
498
+ submitButtonLabel = _ref.submitButtonLabel;
499
+ _ref.size;
500
+ var withCancelLink = _ref.withCancelLink,
501
+ cancelLink = _ref.cancelLink,
502
+ cancelLabel = _ref.cancelLabel,
503
+ props = _objectWithoutProperties__default["default"](_ref, _excluded$1);
504
+
505
+ var defaultPostForm = React.useCallback(function (act, data) {
506
+ return fetch.postJSON(act, data, {
507
+ credentials: 'include',
508
+ headers: fetch.getCSRFHeaders(),
509
+ method: 'DELETE'
510
+ });
511
+ }, []);
512
+ return /*#__PURE__*/React__default["default"].createElement(Form__default["default"], Object.assign({
513
+ action: action,
514
+ submitButtonLabel: submitButtonLabel,
515
+ actions: withCancelLink ? /*#__PURE__*/React__default["default"].createElement(reactRouterDom.Link, {
516
+ className: "py-2 px-4",
517
+ to: cancelLink
518
+ }, cancelLabel) : null,
519
+ postForm: defaultPostForm
520
+ }, props), /*#__PURE__*/React__default["default"].createElement("p", null, explainationLabel));
521
+ };
522
+
523
+ TwoFactorDisable.propTypes = propTypes$1;
524
+ TwoFactorDisable.defaultProps = defaultProps$1;
401
525
 
402
526
  var _excluded = ["action", "fields", "explainationLabel", "submitButtonLabel", "size", "withSkipLink", "skipLink", "skipLabel"];
403
527
  var propTypes = {
@@ -422,10 +546,10 @@ var defaultProps = {
422
546
  }]
423
547
  }),
424
548
  submitButtonLabel: /*#__PURE__*/React__default["default"].createElement(reactIntl.FormattedMessage, {
425
- id: "gj67c0",
549
+ id: "pVHYDd",
426
550
  defaultMessage: [{
427
551
  "type": 0,
428
- "value": "Enable Two Factor authentication"
552
+ "value": "Enable two factor authentication"
429
553
  }]
430
554
  }),
431
555
  withSkipLink: true,
@@ -439,7 +563,7 @@ var defaultProps = {
439
563
  })
440
564
  };
441
565
 
442
- var TwoFactor = function TwoFactor(_ref) {
566
+ var TwoFactorEnable = function TwoFactorEnable(_ref) {
443
567
  var action = _ref.action;
444
568
  _ref.fields;
445
569
  var explainationLabel = _ref.explainationLabel,
@@ -460,12 +584,14 @@ var TwoFactor = function TwoFactor(_ref) {
460
584
  }, props), /*#__PURE__*/React__default["default"].createElement("p", null, explainationLabel));
461
585
  };
462
586
 
463
- TwoFactor.propTypes = propTypes;
464
- TwoFactor.defaultProps = defaultProps;
587
+ TwoFactorEnable.propTypes = propTypes;
588
+ TwoFactorEnable.defaultProps = defaultProps;
465
589
 
466
590
  exports.ConfirmPassword = ConfirmPassword;
467
591
  exports.ForgotPassword = ForgotPassword;
468
592
  exports.Login = Login;
469
593
  exports.Register = Register;
470
594
  exports.ResetPassword = ResetPassword;
471
- exports.TwoFactor = TwoFactor;
595
+ exports.TwoFactorChallenge = TwoFactorChallenge;
596
+ exports.TwoFactorDisable = TwoFactorDisable;
597
+ 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.241",
3
+ "version": "1.0.0-alpha.244",
4
4
  "description": "Basic forgot password form",
5
5
  "keywords": [
6
6
  "javascript"
@@ -46,8 +46,9 @@
46
46
  },
47
47
  "dependencies": {
48
48
  "@babel/runtime": "^7.12.5",
49
- "@panneau/core": "^1.0.0-alpha.237",
50
- "@panneau/form": "^1.0.0-alpha.238",
49
+ "@folklore/fetch": "^0.1.15",
50
+ "@panneau/core": "^1.0.0-alpha.242",
51
+ "@panneau/form": "^1.0.0-alpha.244",
51
52
  "classnames": "^2.2.6",
52
53
  "lodash": "^4.17.21",
53
54
  "prop-types": "^15.7.2",
@@ -57,5 +58,5 @@
57
58
  "publishConfig": {
58
59
  "access": "public"
59
60
  },
60
- "gitHead": "8f58a72c8bfeaca5418c85c53f78434e454a27de"
61
+ "gitHead": "40423ad8eeecd026bf1d9e571ad5f18b68431869"
61
62
  }