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

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 +177 -39
  2. package/lib/index.js +178 -38
  3. package/package.json +4 -3
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,22 +321,30 @@ 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", "currentPasswordLabel", "passwordLabel", "passwordConfirmationLabel", "submitButtonLabel"];
328
+ var propTypes$3 = {
328
329
  action: PropTypes.string,
329
330
  fields: PropTypes$1.fields,
330
331
  size: PropTypes.string,
332
+ currentPasswordLabel: PropTypes$1.label,
331
333
  passwordLabel: PropTypes$1.label,
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',
341
+ currentPasswordLabel: /*#__PURE__*/React.createElement(FormattedMessage, {
342
+ id: "8LSb8C",
343
+ defaultMessage: [{
344
+ "type": 0,
345
+ "value": "Current password"
346
+ }]
347
+ }),
339
348
  passwordLabel: /*#__PURE__*/React.createElement(FormattedMessage, {
340
349
  id: "4yfet+",
341
350
  defaultMessage: [{
@@ -363,14 +372,20 @@ var ResetPassword = function ResetPassword(_ref) {
363
372
  var action = _ref.action,
364
373
  fields = _ref.fields,
365
374
  size = _ref.size,
375
+ currentPasswordLabel = _ref.currentPasswordLabel,
366
376
  passwordLabel = _ref.passwordLabel,
367
377
  passwordConfirmationLabel = _ref.passwordConfirmationLabel,
368
378
  submitButtonLabel = _ref.submitButtonLabel,
369
- props = _objectWithoutProperties(_ref, _excluded$1);
379
+ props = _objectWithoutProperties(_ref, _excluded$3);
370
380
 
371
381
  return /*#__PURE__*/React.createElement(Form, Object.assign({
372
382
  action: action,
373
383
  fields: fields || [{
384
+ name: 'current_password',
385
+ type: 'password',
386
+ size: size,
387
+ label: currentPasswordLabel
388
+ }, {
374
389
  name: 'password',
375
390
  type: 'password',
376
391
  size: size,
@@ -385,8 +400,131 @@ var ResetPassword = function ResetPassword(_ref) {
385
400
  }, props));
386
401
  };
387
402
 
388
- ResetPassword.propTypes = propTypes$1;
389
- ResetPassword.defaultProps = defaultProps$1;
403
+ ResetPassword.propTypes = propTypes$3;
404
+ ResetPassword.defaultProps = defaultProps$3;
405
+
406
+ var _excluded$2 = ["action", "fields", "size", "codeLabel", "submitButtonLabel"];
407
+ var propTypes$2 = {
408
+ action: PropTypes.string,
409
+ fields: PropTypes$1.fields,
410
+ size: PropTypes.string,
411
+ codeLabel: PropTypes$1.label,
412
+ submitButtonLabel: PropTypes$1.label
413
+ };
414
+ var defaultProps$2 = {
415
+ action: '/two-factor-challenge',
416
+ fields: null,
417
+ size: 'lg',
418
+ codeLabel: /*#__PURE__*/React.createElement(FormattedMessage, {
419
+ id: "22Ld5M",
420
+ defaultMessage: [{
421
+ "type": 0,
422
+ "value": "Enter the code from your authenticator app to continue"
423
+ }]
424
+ }),
425
+ submitButtonLabel: /*#__PURE__*/React.createElement(FormattedMessage, {
426
+ id: "QUAHwy",
427
+ defaultMessage: [{
428
+ "type": 0,
429
+ "value": "Continue"
430
+ }]
431
+ })
432
+ };
433
+
434
+ var TwoFactorChallenge = function TwoFactorChallenge(_ref) {
435
+ var action = _ref.action,
436
+ fields = _ref.fields,
437
+ size = _ref.size,
438
+ codeLabel = _ref.codeLabel,
439
+ submitButtonLabel = _ref.submitButtonLabel,
440
+ props = _objectWithoutProperties(_ref, _excluded$2);
441
+
442
+ return /*#__PURE__*/React.createElement(Form, Object.assign({
443
+ action: action,
444
+ fields: fields || [{
445
+ name: 'code',
446
+ type: 'text',
447
+ size: size,
448
+ label: codeLabel
449
+ }],
450
+ submitButtonLabel: submitButtonLabel
451
+ }, props));
452
+ };
453
+
454
+ TwoFactorChallenge.propTypes = propTypes$2;
455
+ TwoFactorChallenge.defaultProps = defaultProps$2;
456
+
457
+ var _excluded$1 = ["action", "fields", "explainationLabel", "submitButtonLabel", "size", "withCancelLink", "cancelLink", "cancelLabel"];
458
+ var propTypes$1 = {
459
+ action: PropTypes.string,
460
+ fields: PropTypes$1.fields,
461
+ size: PropTypes.string,
462
+ explainationLabel: PropTypes$1.label,
463
+ submitButtonLabel: PropTypes$1.label,
464
+ withCancelLink: PropTypes.bool,
465
+ cancelLink: PropTypes.string,
466
+ cancelLabel: PropTypes$1.label
467
+ };
468
+ var defaultProps$1 = {
469
+ action: '/user/two-factor-authentication',
470
+ fields: null,
471
+ size: 'lg',
472
+ explainationLabel: /*#__PURE__*/React.createElement(FormattedMessage, {
473
+ id: "5nHK/H",
474
+ defaultMessage: [{
475
+ "type": 0,
476
+ "value": "Do you really wish to disable two factor authentication on your account?"
477
+ }]
478
+ }),
479
+ submitButtonLabel: /*#__PURE__*/React.createElement(FormattedMessage, {
480
+ id: "gWmL5V",
481
+ defaultMessage: [{
482
+ "type": 0,
483
+ "value": "Disable two factor authentication"
484
+ }]
485
+ }),
486
+ withCancelLink: true,
487
+ cancelLink: '/home',
488
+ cancelLabel: /*#__PURE__*/React.createElement(FormattedMessage, {
489
+ id: "U/ye2x",
490
+ defaultMessage: [{
491
+ "type": 0,
492
+ "value": "Cancel"
493
+ }]
494
+ })
495
+ };
496
+
497
+ var TwoFactorDisable = function TwoFactorDisable(_ref) {
498
+ var action = _ref.action;
499
+ _ref.fields;
500
+ var explainationLabel = _ref.explainationLabel,
501
+ submitButtonLabel = _ref.submitButtonLabel;
502
+ _ref.size;
503
+ var withCancelLink = _ref.withCancelLink,
504
+ cancelLink = _ref.cancelLink,
505
+ cancelLabel = _ref.cancelLabel,
506
+ props = _objectWithoutProperties(_ref, _excluded$1);
507
+
508
+ var defaultPostForm = useCallback(function (act, data) {
509
+ return postJSON(act, data, {
510
+ credentials: 'include',
511
+ headers: getCSRFHeaders(),
512
+ method: 'DELETE'
513
+ });
514
+ }, []);
515
+ return /*#__PURE__*/React.createElement(Form, Object.assign({
516
+ action: action,
517
+ submitButtonLabel: submitButtonLabel,
518
+ actions: withCancelLink ? /*#__PURE__*/React.createElement(Link, {
519
+ className: "py-2 px-4",
520
+ to: cancelLink
521
+ }, cancelLabel) : null,
522
+ postForm: defaultPostForm
523
+ }, props), /*#__PURE__*/React.createElement("p", null, explainationLabel));
524
+ };
525
+
526
+ TwoFactorDisable.propTypes = propTypes$1;
527
+ TwoFactorDisable.defaultProps = defaultProps$1;
390
528
 
391
529
  var _excluded = ["action", "fields", "explainationLabel", "submitButtonLabel", "size", "withSkipLink", "skipLink", "skipLabel"];
392
530
  var propTypes = {
@@ -411,10 +549,10 @@ var defaultProps = {
411
549
  }]
412
550
  }),
413
551
  submitButtonLabel: /*#__PURE__*/React.createElement(FormattedMessage, {
414
- id: "gj67c0",
552
+ id: "pVHYDd",
415
553
  defaultMessage: [{
416
554
  "type": 0,
417
- "value": "Enable Two Factor authentication"
555
+ "value": "Enable two factor authentication"
418
556
  }]
419
557
  }),
420
558
  withSkipLink: true,
@@ -428,7 +566,7 @@ var defaultProps = {
428
566
  })
429
567
  };
430
568
 
431
- var TwoFactor = function TwoFactor(_ref) {
569
+ var TwoFactorEnable = function TwoFactorEnable(_ref) {
432
570
  var action = _ref.action;
433
571
  _ref.fields;
434
572
  var explainationLabel = _ref.explainationLabel,
@@ -449,7 +587,7 @@ var TwoFactor = function TwoFactor(_ref) {
449
587
  }, props), /*#__PURE__*/React.createElement("p", null, explainationLabel));
450
588
  };
451
589
 
452
- TwoFactor.propTypes = propTypes;
453
- TwoFactor.defaultProps = defaultProps;
590
+ TwoFactorEnable.propTypes = propTypes;
591
+ TwoFactorEnable.defaultProps = defaultProps;
454
592
 
455
- export { ConfirmPassword, ForgotPassword, Login, Register, ResetPassword, TwoFactor };
593
+ 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,22 +332,30 @@ 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", "currentPasswordLabel", "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
+ currentPasswordLabel: core.PropTypes.label,
342
344
  passwordLabel: core.PropTypes.label,
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',
352
+ currentPasswordLabel: /*#__PURE__*/React__default["default"].createElement(reactIntl.FormattedMessage, {
353
+ id: "8LSb8C",
354
+ defaultMessage: [{
355
+ "type": 0,
356
+ "value": "Current password"
357
+ }]
358
+ }),
350
359
  passwordLabel: /*#__PURE__*/React__default["default"].createElement(reactIntl.FormattedMessage, {
351
360
  id: "4yfet+",
352
361
  defaultMessage: [{
@@ -374,14 +383,20 @@ var ResetPassword = function ResetPassword(_ref) {
374
383
  var action = _ref.action,
375
384
  fields = _ref.fields,
376
385
  size = _ref.size,
386
+ currentPasswordLabel = _ref.currentPasswordLabel,
377
387
  passwordLabel = _ref.passwordLabel,
378
388
  passwordConfirmationLabel = _ref.passwordConfirmationLabel,
379
389
  submitButtonLabel = _ref.submitButtonLabel,
380
- props = _objectWithoutProperties__default["default"](_ref, _excluded$1);
390
+ props = _objectWithoutProperties__default["default"](_ref, _excluded$3);
381
391
 
382
392
  return /*#__PURE__*/React__default["default"].createElement(Form__default["default"], Object.assign({
383
393
  action: action,
384
394
  fields: fields || [{
395
+ name: 'current_password',
396
+ type: 'password',
397
+ size: size,
398
+ label: currentPasswordLabel
399
+ }, {
385
400
  name: 'password',
386
401
  type: 'password',
387
402
  size: size,
@@ -396,8 +411,131 @@ var ResetPassword = function ResetPassword(_ref) {
396
411
  }, props));
397
412
  };
398
413
 
399
- ResetPassword.propTypes = propTypes$1;
400
- ResetPassword.defaultProps = defaultProps$1;
414
+ ResetPassword.propTypes = propTypes$3;
415
+ ResetPassword.defaultProps = defaultProps$3;
416
+
417
+ var _excluded$2 = ["action", "fields", "size", "codeLabel", "submitButtonLabel"];
418
+ var propTypes$2 = {
419
+ action: PropTypes__default["default"].string,
420
+ fields: core.PropTypes.fields,
421
+ size: PropTypes__default["default"].string,
422
+ codeLabel: core.PropTypes.label,
423
+ submitButtonLabel: core.PropTypes.label
424
+ };
425
+ var defaultProps$2 = {
426
+ action: '/two-factor-challenge',
427
+ fields: null,
428
+ size: 'lg',
429
+ codeLabel: /*#__PURE__*/React__default["default"].createElement(reactIntl.FormattedMessage, {
430
+ id: "22Ld5M",
431
+ defaultMessage: [{
432
+ "type": 0,
433
+ "value": "Enter the code from your authenticator app to continue"
434
+ }]
435
+ }),
436
+ submitButtonLabel: /*#__PURE__*/React__default["default"].createElement(reactIntl.FormattedMessage, {
437
+ id: "QUAHwy",
438
+ defaultMessage: [{
439
+ "type": 0,
440
+ "value": "Continue"
441
+ }]
442
+ })
443
+ };
444
+
445
+ var TwoFactorChallenge = function TwoFactorChallenge(_ref) {
446
+ var action = _ref.action,
447
+ fields = _ref.fields,
448
+ size = _ref.size,
449
+ codeLabel = _ref.codeLabel,
450
+ submitButtonLabel = _ref.submitButtonLabel,
451
+ props = _objectWithoutProperties__default["default"](_ref, _excluded$2);
452
+
453
+ return /*#__PURE__*/React__default["default"].createElement(Form__default["default"], Object.assign({
454
+ action: action,
455
+ fields: fields || [{
456
+ name: 'code',
457
+ type: 'text',
458
+ size: size,
459
+ label: codeLabel
460
+ }],
461
+ submitButtonLabel: submitButtonLabel
462
+ }, props));
463
+ };
464
+
465
+ TwoFactorChallenge.propTypes = propTypes$2;
466
+ TwoFactorChallenge.defaultProps = defaultProps$2;
467
+
468
+ var _excluded$1 = ["action", "fields", "explainationLabel", "submitButtonLabel", "size", "withCancelLink", "cancelLink", "cancelLabel"];
469
+ var propTypes$1 = {
470
+ action: PropTypes__default["default"].string,
471
+ fields: core.PropTypes.fields,
472
+ size: PropTypes__default["default"].string,
473
+ explainationLabel: core.PropTypes.label,
474
+ submitButtonLabel: core.PropTypes.label,
475
+ withCancelLink: PropTypes__default["default"].bool,
476
+ cancelLink: PropTypes__default["default"].string,
477
+ cancelLabel: core.PropTypes.label
478
+ };
479
+ var defaultProps$1 = {
480
+ action: '/user/two-factor-authentication',
481
+ fields: null,
482
+ size: 'lg',
483
+ explainationLabel: /*#__PURE__*/React__default["default"].createElement(reactIntl.FormattedMessage, {
484
+ id: "5nHK/H",
485
+ defaultMessage: [{
486
+ "type": 0,
487
+ "value": "Do you really wish to disable two factor authentication on your account?"
488
+ }]
489
+ }),
490
+ submitButtonLabel: /*#__PURE__*/React__default["default"].createElement(reactIntl.FormattedMessage, {
491
+ id: "gWmL5V",
492
+ defaultMessage: [{
493
+ "type": 0,
494
+ "value": "Disable two factor authentication"
495
+ }]
496
+ }),
497
+ withCancelLink: true,
498
+ cancelLink: '/home',
499
+ cancelLabel: /*#__PURE__*/React__default["default"].createElement(reactIntl.FormattedMessage, {
500
+ id: "U/ye2x",
501
+ defaultMessage: [{
502
+ "type": 0,
503
+ "value": "Cancel"
504
+ }]
505
+ })
506
+ };
507
+
508
+ var TwoFactorDisable = function TwoFactorDisable(_ref) {
509
+ var action = _ref.action;
510
+ _ref.fields;
511
+ var explainationLabel = _ref.explainationLabel,
512
+ submitButtonLabel = _ref.submitButtonLabel;
513
+ _ref.size;
514
+ var withCancelLink = _ref.withCancelLink,
515
+ cancelLink = _ref.cancelLink,
516
+ cancelLabel = _ref.cancelLabel,
517
+ props = _objectWithoutProperties__default["default"](_ref, _excluded$1);
518
+
519
+ var defaultPostForm = React.useCallback(function (act, data) {
520
+ return fetch.postJSON(act, data, {
521
+ credentials: 'include',
522
+ headers: fetch.getCSRFHeaders(),
523
+ method: 'DELETE'
524
+ });
525
+ }, []);
526
+ return /*#__PURE__*/React__default["default"].createElement(Form__default["default"], Object.assign({
527
+ action: action,
528
+ submitButtonLabel: submitButtonLabel,
529
+ actions: withCancelLink ? /*#__PURE__*/React__default["default"].createElement(reactRouterDom.Link, {
530
+ className: "py-2 px-4",
531
+ to: cancelLink
532
+ }, cancelLabel) : null,
533
+ postForm: defaultPostForm
534
+ }, props), /*#__PURE__*/React__default["default"].createElement("p", null, explainationLabel));
535
+ };
536
+
537
+ TwoFactorDisable.propTypes = propTypes$1;
538
+ TwoFactorDisable.defaultProps = defaultProps$1;
401
539
 
402
540
  var _excluded = ["action", "fields", "explainationLabel", "submitButtonLabel", "size", "withSkipLink", "skipLink", "skipLabel"];
403
541
  var propTypes = {
@@ -422,10 +560,10 @@ var defaultProps = {
422
560
  }]
423
561
  }),
424
562
  submitButtonLabel: /*#__PURE__*/React__default["default"].createElement(reactIntl.FormattedMessage, {
425
- id: "gj67c0",
563
+ id: "pVHYDd",
426
564
  defaultMessage: [{
427
565
  "type": 0,
428
- "value": "Enable Two Factor authentication"
566
+ "value": "Enable two factor authentication"
429
567
  }]
430
568
  }),
431
569
  withSkipLink: true,
@@ -439,7 +577,7 @@ var defaultProps = {
439
577
  })
440
578
  };
441
579
 
442
- var TwoFactor = function TwoFactor(_ref) {
580
+ var TwoFactorEnable = function TwoFactorEnable(_ref) {
443
581
  var action = _ref.action;
444
582
  _ref.fields;
445
583
  var explainationLabel = _ref.explainationLabel,
@@ -460,12 +598,14 @@ var TwoFactor = function TwoFactor(_ref) {
460
598
  }, props), /*#__PURE__*/React__default["default"].createElement("p", null, explainationLabel));
461
599
  };
462
600
 
463
- TwoFactor.propTypes = propTypes;
464
- TwoFactor.defaultProps = defaultProps;
601
+ TwoFactorEnable.propTypes = propTypes;
602
+ TwoFactorEnable.defaultProps = defaultProps;
465
603
 
466
604
  exports.ConfirmPassword = ConfirmPassword;
467
605
  exports.ForgotPassword = ForgotPassword;
468
606
  exports.Login = Login;
469
607
  exports.Register = Register;
470
608
  exports.ResetPassword = ResetPassword;
471
- exports.TwoFactor = TwoFactor;
609
+ exports.TwoFactorChallenge = TwoFactorChallenge;
610
+ exports.TwoFactorDisable = TwoFactorDisable;
611
+ 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.245",
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
+ "@folklore/fetch": "^0.1.15",
49
50
  "@panneau/core": "^1.0.0-alpha.242",
50
- "@panneau/form": "^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": "642186399b25e090f6fa3a210d14f195e2121a38"
61
+ "gitHead": "9d948c9236716fbb3e1d2dbb36bb392ccaee63a6"
61
62
  }