@panneau/form-auth 1.0.0-alpha.236 → 1.0.0-alpha.240

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 +278 -51
  2. package/lib/index.js +280 -51
  3. package/package.json +8 -6
package/es/index.js CHANGED
@@ -4,15 +4,21 @@ 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", "size"];
9
- var propTypes$2 = {
10
- action: PropTypes.string.isRequired,
9
+ var _excluded$4 = ["action", "fields", "emailLabel", "submitButtonLabel", "size", "withLoginLink", "loginLink", "loginLabel"];
10
+ var propTypes$4 = {
11
+ action: PropTypes.string,
11
12
  fields: PropTypes$1.fields,
12
13
  size: PropTypes.string,
13
- emailLabel: PropTypes$1.message
14
+ emailLabel: PropTypes$1.label,
15
+ submitButtonLabel: PropTypes$1.label,
16
+ withLoginLink: PropTypes.bool,
17
+ loginLink: PropTypes.string,
18
+ loginLabel: PropTypes$1.label
14
19
  };
15
- var defaultProps$2 = {
20
+ var defaultProps$4 = {
21
+ action: '/forgot-password',
16
22
  fields: null,
17
23
  size: 'lg',
18
24
  emailLabel: /*#__PURE__*/React.createElement(FormattedMessage, {
@@ -21,6 +27,22 @@ var defaultProps$2 = {
21
27
  "type": 0,
22
28
  "value": "Email"
23
29
  }]
30
+ }),
31
+ submitButtonLabel: /*#__PURE__*/React.createElement(FormattedMessage, {
32
+ id: "12Px0g",
33
+ defaultMessage: [{
34
+ "type": 0,
35
+ "value": "Send reset link"
36
+ }]
37
+ }),
38
+ withLoginLink: true,
39
+ loginLink: '/login',
40
+ loginLabel: /*#__PURE__*/React.createElement(FormattedMessage, {
41
+ id: "tPeIKO",
42
+ defaultMessage: [{
43
+ "type": 0,
44
+ "value": "Go back to login"
45
+ }]
24
46
  })
25
47
  };
26
48
 
@@ -28,8 +50,12 @@ var ForgotPassword = function ForgotPassword(_ref) {
28
50
  var action = _ref.action,
29
51
  fields = _ref.fields,
30
52
  emailLabel = _ref.emailLabel,
53
+ submitButtonLabel = _ref.submitButtonLabel,
31
54
  size = _ref.size,
32
- props = _objectWithoutProperties(_ref, _excluded$2);
55
+ withLoginLink = _ref.withLoginLink,
56
+ loginLink = _ref.loginLink,
57
+ loginLabel = _ref.loginLabel,
58
+ props = _objectWithoutProperties(_ref, _excluded$4);
33
59
 
34
60
  return /*#__PURE__*/React.createElement(Form, Object.assign({
35
61
  action: action,
@@ -39,28 +65,31 @@ var ForgotPassword = function ForgotPassword(_ref) {
39
65
  size: size,
40
66
  label: emailLabel
41
67
  }],
42
- submitButtonLabel: /*#__PURE__*/React.createElement(FormattedMessage, {
43
- id: "12Px0g",
44
- defaultMessage: [{
45
- "type": 0,
46
- "value": "Send reset link"
47
- }]
48
- })
68
+ submitButtonLabel: submitButtonLabel,
69
+ actions: withLoginLink ? /*#__PURE__*/React.createElement(Link, {
70
+ className: "py-2 px-4",
71
+ to: loginLink
72
+ }, loginLabel) : null
49
73
  }, props));
50
74
  };
51
75
 
52
- ForgotPassword.propTypes = propTypes$2;
53
- ForgotPassword.defaultProps = defaultProps$2;
76
+ ForgotPassword.propTypes = propTypes$4;
77
+ ForgotPassword.defaultProps = defaultProps$4;
54
78
 
55
- var _excluded$1 = ["action", "fields", "size", "emailLabel", "passwordLabel"];
56
- var propTypes$1 = {
57
- action: PropTypes.string.isRequired,
79
+ var _excluded$3 = ["action", "fields", "size", "emailLabel", "passwordLabel", "submitButtonLabel", "withForgotPassword", "forgotPasswordLink", "forgotPasswordLabel"];
80
+ var propTypes$3 = {
81
+ action: PropTypes.string,
58
82
  fields: PropTypes$1.fields,
59
83
  size: PropTypes.string,
60
- emailLabel: PropTypes$1.message,
61
- passwordLabel: PropTypes$1.message
84
+ emailLabel: PropTypes$1.label,
85
+ passwordLabel: PropTypes$1.label,
86
+ submitButtonLabel: PropTypes$1.label,
87
+ withForgotPassword: PropTypes.bool,
88
+ forgotPasswordLink: PropTypes.string,
89
+ forgotPasswordLabel: PropTypes$1.label
62
90
  };
63
- var defaultProps$1 = {
91
+ var defaultProps$3 = {
92
+ action: '/login',
64
93
  fields: null,
65
94
  size: 'lg',
66
95
  emailLabel: /*#__PURE__*/React.createElement(FormattedMessage, {
@@ -76,16 +105,36 @@ var defaultProps$1 = {
76
105
  "type": 0,
77
106
  "value": "Password"
78
107
  }]
108
+ }),
109
+ submitButtonLabel: /*#__PURE__*/React.createElement(FormattedMessage, {
110
+ id: "g6qbbX",
111
+ defaultMessage: [{
112
+ "type": 0,
113
+ "value": "Log in"
114
+ }]
115
+ }),
116
+ withForgotPassword: true,
117
+ forgotPasswordLink: '/forgot-password',
118
+ forgotPasswordLabel: /*#__PURE__*/React.createElement(FormattedMessage, {
119
+ id: "ZBNqY2",
120
+ defaultMessage: [{
121
+ "type": 0,
122
+ "value": "Forgot your password?"
123
+ }]
79
124
  })
80
125
  };
81
126
 
82
- var LoginForm = function LoginForm(_ref) {
127
+ var Login = function Login(_ref) {
83
128
  var action = _ref.action,
84
129
  fields = _ref.fields,
85
130
  size = _ref.size,
86
131
  emailLabel = _ref.emailLabel,
87
132
  passwordLabel = _ref.passwordLabel,
88
- props = _objectWithoutProperties(_ref, _excluded$1);
133
+ submitButtonLabel = _ref.submitButtonLabel,
134
+ withForgotPassword = _ref.withForgotPassword,
135
+ forgotPasswordLink = _ref.forgotPasswordLink,
136
+ forgotPasswordLabel = _ref.forgotPasswordLabel,
137
+ props = _objectWithoutProperties(_ref, _excluded$3);
89
138
 
90
139
  return /*#__PURE__*/React.createElement(Form, Object.assign({
91
140
  action: action,
@@ -100,30 +149,49 @@ var LoginForm = function LoginForm(_ref) {
100
149
  size: size,
101
150
  label: passwordLabel
102
151
  }],
103
- submitButtonLabel: /*#__PURE__*/React.createElement(FormattedMessage, {
104
- id: "g6qbbX",
105
- defaultMessage: [{
106
- "type": 0,
107
- "value": "Log in"
108
- }]
109
- })
152
+ submitButtonLabel: submitButtonLabel,
153
+ actions: withForgotPassword ? /*#__PURE__*/React.createElement(Link, {
154
+ className: "py-2 px-4",
155
+ to: forgotPasswordLink
156
+ }, forgotPasswordLabel) : null
110
157
  }, props));
111
158
  };
112
159
 
113
- LoginForm.propTypes = propTypes$1;
114
- LoginForm.defaultProps = defaultProps$1;
160
+ Login.propTypes = propTypes$3;
161
+ Login.defaultProps = defaultProps$3;
115
162
 
116
- var _excluded = ["action", "fields", "size", "passwordLabel", "passwordConfirmationLabel"];
117
- var propTypes = {
118
- action: PropTypes.string.isRequired,
163
+ var _excluded$2 = ["action", "fields", "size", "nameLabel", "emailLabel", "passwordLabel", "passwordConfirmationLabel", "submitButtonLabel", "withLoginLink", "loginLink", "loginLabel"];
164
+ var propTypes$2 = {
165
+ action: PropTypes.string,
119
166
  fields: PropTypes$1.fields,
120
167
  size: PropTypes.string,
121
- passwordLabel: PropTypes$1.message,
122
- passwordConfirmationLabel: PropTypes$1.message
168
+ nameLabel: PropTypes$1.label,
169
+ emailLabel: PropTypes$1.label,
170
+ passwordLabel: PropTypes$1.label,
171
+ passwordConfirmationLabel: PropTypes$1.label,
172
+ submitButtonLabel: PropTypes$1.label,
173
+ withLoginLink: PropTypes.bool,
174
+ loginLink: PropTypes.string,
175
+ loginLabel: PropTypes$1.label
123
176
  };
124
- var defaultProps = {
177
+ var defaultProps$2 = {
178
+ action: '/register',
125
179
  fields: null,
126
180
  size: 'lg',
181
+ nameLabel: /*#__PURE__*/React.createElement(FormattedMessage, {
182
+ id: "UUv8FR",
183
+ defaultMessage: [{
184
+ "type": 0,
185
+ "value": "Name"
186
+ }]
187
+ }),
188
+ emailLabel: /*#__PURE__*/React.createElement(FormattedMessage, {
189
+ id: "LI0Gz4",
190
+ defaultMessage: [{
191
+ "type": 0,
192
+ "value": "Email"
193
+ }]
194
+ }),
127
195
  passwordLabel: /*#__PURE__*/React.createElement(FormattedMessage, {
128
196
  id: "4yfet+",
129
197
  defaultMessage: [{
@@ -132,10 +200,110 @@ var defaultProps = {
132
200
  }]
133
201
  }),
134
202
  passwordConfirmationLabel: /*#__PURE__*/React.createElement(FormattedMessage, {
135
- id: "SdtI90",
203
+ id: "VhJUeW",
136
204
  defaultMessage: [{
137
205
  "type": 0,
138
- "value": "Password confirmation"
206
+ "value": "Confirm your password"
207
+ }]
208
+ }),
209
+ submitButtonLabel: /*#__PURE__*/React.createElement(FormattedMessage, {
210
+ id: "PQX/ph",
211
+ defaultMessage: [{
212
+ "type": 0,
213
+ "value": "Create account"
214
+ }]
215
+ }),
216
+ withLoginLink: true,
217
+ loginLink: '/forgot-password',
218
+ loginLabel: /*#__PURE__*/React.createElement(FormattedMessage, {
219
+ id: "wa783M",
220
+ defaultMessage: [{
221
+ "type": 0,
222
+ "value": "Already have an account? Go to login"
223
+ }]
224
+ })
225
+ };
226
+
227
+ var Register = function Register(_ref) {
228
+ var action = _ref.action,
229
+ fields = _ref.fields,
230
+ size = _ref.size,
231
+ nameLabel = _ref.nameLabel,
232
+ emailLabel = _ref.emailLabel,
233
+ passwordLabel = _ref.passwordLabel,
234
+ passwordConfirmationLabel = _ref.passwordConfirmationLabel,
235
+ submitButtonLabel = _ref.submitButtonLabel,
236
+ withLoginLink = _ref.withLoginLink,
237
+ loginLink = _ref.loginLink,
238
+ loginLabel = _ref.loginLabel,
239
+ props = _objectWithoutProperties(_ref, _excluded$2);
240
+
241
+ return /*#__PURE__*/React.createElement(Form, Object.assign({
242
+ action: action,
243
+ fields: fields || [{
244
+ name: 'name',
245
+ type: 'text',
246
+ size: size,
247
+ label: nameLabel
248
+ }, {
249
+ name: 'email',
250
+ type: 'email',
251
+ size: size,
252
+ label: emailLabel
253
+ }, {
254
+ name: 'password',
255
+ type: 'password',
256
+ size: size,
257
+ label: passwordLabel
258
+ }, {
259
+ name: 'password_confirmation',
260
+ type: 'password',
261
+ size: size,
262
+ label: passwordConfirmationLabel
263
+ }],
264
+ submitButtonLabel: submitButtonLabel,
265
+ actions: withLoginLink ? /*#__PURE__*/React.createElement(Link, {
266
+ className: "py-2 px-4",
267
+ to: loginLink
268
+ }, loginLabel) : null
269
+ }, props));
270
+ };
271
+
272
+ Register.propTypes = propTypes$2;
273
+ Register.defaultProps = defaultProps$2;
274
+
275
+ var _excluded$1 = ["action", "fields", "size", "passwordLabel", "passwordConfirmationLabel", "submitButtonLabel"];
276
+ var propTypes$1 = {
277
+ action: PropTypes.string,
278
+ fields: PropTypes$1.fields,
279
+ size: PropTypes.string,
280
+ passwordLabel: PropTypes$1.label,
281
+ passwordConfirmationLabel: PropTypes$1.label,
282
+ submitButtonLabel: PropTypes$1.label
283
+ };
284
+ var defaultProps$1 = {
285
+ action: '/reset-password',
286
+ fields: null,
287
+ size: 'lg',
288
+ passwordLabel: /*#__PURE__*/React.createElement(FormattedMessage, {
289
+ id: "4yfet+",
290
+ defaultMessage: [{
291
+ "type": 0,
292
+ "value": "Password"
293
+ }]
294
+ }),
295
+ passwordConfirmationLabel: /*#__PURE__*/React.createElement(FormattedMessage, {
296
+ id: "VhJUeW",
297
+ defaultMessage: [{
298
+ "type": 0,
299
+ "value": "Confirm your password"
300
+ }]
301
+ }),
302
+ submitButtonLabel: /*#__PURE__*/React.createElement(FormattedMessage, {
303
+ id: "zwks3g",
304
+ defaultMessage: [{
305
+ "type": 0,
306
+ "value": "Save new password"
139
307
  }]
140
308
  })
141
309
  };
@@ -146,7 +314,8 @@ var ResetPassword = function ResetPassword(_ref) {
146
314
  size = _ref.size,
147
315
  passwordLabel = _ref.passwordLabel,
148
316
  passwordConfirmationLabel = _ref.passwordConfirmationLabel,
149
- props = _objectWithoutProperties(_ref, _excluded);
317
+ submitButtonLabel = _ref.submitButtonLabel,
318
+ props = _objectWithoutProperties(_ref, _excluded$1);
150
319
 
151
320
  return /*#__PURE__*/React.createElement(Form, Object.assign({
152
321
  action: action,
@@ -161,17 +330,75 @@ var ResetPassword = function ResetPassword(_ref) {
161
330
  size: size,
162
331
  label: passwordConfirmationLabel
163
332
  }],
164
- submitButtonLabel: /*#__PURE__*/React.createElement(FormattedMessage, {
165
- id: "zwks3g",
166
- defaultMessage: [{
167
- "type": 0,
168
- "value": "Save new password"
169
- }]
170
- })
333
+ submitButtonLabel: submitButtonLabel
171
334
  }, props));
172
335
  };
173
336
 
174
- ResetPassword.propTypes = propTypes;
175
- ResetPassword.defaultProps = defaultProps;
337
+ ResetPassword.propTypes = propTypes$1;
338
+ ResetPassword.defaultProps = defaultProps$1;
339
+
340
+ var _excluded = ["action", "fields", "explainationLabel", "submitButtonLabel", "size", "withSkipLink", "skipLink", "skipLabel"];
341
+ var propTypes = {
342
+ action: PropTypes.string,
343
+ fields: PropTypes$1.fields,
344
+ size: PropTypes.string,
345
+ explainationLabel: PropTypes$1.label,
346
+ submitButtonLabel: PropTypes$1.label,
347
+ withSkipLink: PropTypes.bool,
348
+ skipLink: PropTypes.string,
349
+ skipLabel: PropTypes$1.label
350
+ };
351
+ var defaultProps = {
352
+ action: '/user/two-factor-authentication',
353
+ fields: null,
354
+ size: 'lg',
355
+ explainationLabel: /*#__PURE__*/React.createElement(FormattedMessage, {
356
+ id: "zTiC4D",
357
+ defaultMessage: [{
358
+ "type": 0,
359
+ "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."
360
+ }]
361
+ }),
362
+ submitButtonLabel: /*#__PURE__*/React.createElement(FormattedMessage, {
363
+ id: "gj67c0",
364
+ defaultMessage: [{
365
+ "type": 0,
366
+ "value": "Enable Two Factor authentication"
367
+ }]
368
+ }),
369
+ withSkipLink: true,
370
+ skipLink: '/home',
371
+ skipLabel: /*#__PURE__*/React.createElement(FormattedMessage, {
372
+ id: "li2Qqu",
373
+ defaultMessage: [{
374
+ "type": 0,
375
+ "value": "Skip setup"
376
+ }]
377
+ })
378
+ };
379
+
380
+ var TwoFactor = function TwoFactor(_ref) {
381
+ var action = _ref.action;
382
+ _ref.fields;
383
+ var explainationLabel = _ref.explainationLabel,
384
+ submitButtonLabel = _ref.submitButtonLabel;
385
+ _ref.size;
386
+ var withSkipLink = _ref.withSkipLink,
387
+ skipLink = _ref.skipLink,
388
+ skipLabel = _ref.skipLabel,
389
+ props = _objectWithoutProperties(_ref, _excluded);
390
+
391
+ return /*#__PURE__*/React.createElement(Form, Object.assign({
392
+ action: action,
393
+ submitButtonLabel: submitButtonLabel,
394
+ actions: withSkipLink ? /*#__PURE__*/React.createElement(Link, {
395
+ className: "py-2 px-4",
396
+ to: skipLink
397
+ }, skipLabel) : null
398
+ }, props), /*#__PURE__*/React.createElement("p", null, explainationLabel));
399
+ };
400
+
401
+ TwoFactor.propTypes = propTypes;
402
+ TwoFactor.defaultProps = defaultProps;
176
403
 
177
- export { ForgotPassword, LoginForm as Login, ResetPassword };
404
+ export { 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,14 +17,19 @@ 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", "size"];
20
- var propTypes$2 = {
21
- action: PropTypes__default["default"].string.isRequired,
20
+ var _excluded$4 = ["action", "fields", "emailLabel", "submitButtonLabel", "size", "withLoginLink", "loginLink", "loginLabel"];
21
+ var propTypes$4 = {
22
+ action: PropTypes__default["default"].string,
22
23
  fields: core.PropTypes.fields,
23
24
  size: PropTypes__default["default"].string,
24
- emailLabel: core.PropTypes.message
25
+ emailLabel: core.PropTypes.label,
26
+ submitButtonLabel: core.PropTypes.label,
27
+ withLoginLink: PropTypes__default["default"].bool,
28
+ loginLink: PropTypes__default["default"].string,
29
+ loginLabel: core.PropTypes.label
25
30
  };
26
- var defaultProps$2 = {
31
+ var defaultProps$4 = {
32
+ action: '/forgot-password',
27
33
  fields: null,
28
34
  size: 'lg',
29
35
  emailLabel: /*#__PURE__*/React__default["default"].createElement(reactIntl.FormattedMessage, {
@@ -32,6 +38,22 @@ var defaultProps$2 = {
32
38
  "type": 0,
33
39
  "value": "Email"
34
40
  }]
41
+ }),
42
+ submitButtonLabel: /*#__PURE__*/React__default["default"].createElement(reactIntl.FormattedMessage, {
43
+ id: "12Px0g",
44
+ defaultMessage: [{
45
+ "type": 0,
46
+ "value": "Send reset link"
47
+ }]
48
+ }),
49
+ withLoginLink: true,
50
+ loginLink: '/login',
51
+ loginLabel: /*#__PURE__*/React__default["default"].createElement(reactIntl.FormattedMessage, {
52
+ id: "tPeIKO",
53
+ defaultMessage: [{
54
+ "type": 0,
55
+ "value": "Go back to login"
56
+ }]
35
57
  })
36
58
  };
37
59
 
@@ -39,8 +61,12 @@ var ForgotPassword = function ForgotPassword(_ref) {
39
61
  var action = _ref.action,
40
62
  fields = _ref.fields,
41
63
  emailLabel = _ref.emailLabel,
64
+ submitButtonLabel = _ref.submitButtonLabel,
42
65
  size = _ref.size,
43
- props = _objectWithoutProperties__default["default"](_ref, _excluded$2);
66
+ withLoginLink = _ref.withLoginLink,
67
+ loginLink = _ref.loginLink,
68
+ loginLabel = _ref.loginLabel,
69
+ props = _objectWithoutProperties__default["default"](_ref, _excluded$4);
44
70
 
45
71
  return /*#__PURE__*/React__default["default"].createElement(Form__default["default"], Object.assign({
46
72
  action: action,
@@ -50,28 +76,31 @@ var ForgotPassword = function ForgotPassword(_ref) {
50
76
  size: size,
51
77
  label: emailLabel
52
78
  }],
53
- submitButtonLabel: /*#__PURE__*/React__default["default"].createElement(reactIntl.FormattedMessage, {
54
- id: "12Px0g",
55
- defaultMessage: [{
56
- "type": 0,
57
- "value": "Send reset link"
58
- }]
59
- })
79
+ submitButtonLabel: submitButtonLabel,
80
+ actions: withLoginLink ? /*#__PURE__*/React__default["default"].createElement(reactRouterDom.Link, {
81
+ className: "py-2 px-4",
82
+ to: loginLink
83
+ }, loginLabel) : null
60
84
  }, props));
61
85
  };
62
86
 
63
- ForgotPassword.propTypes = propTypes$2;
64
- ForgotPassword.defaultProps = defaultProps$2;
87
+ ForgotPassword.propTypes = propTypes$4;
88
+ ForgotPassword.defaultProps = defaultProps$4;
65
89
 
66
- var _excluded$1 = ["action", "fields", "size", "emailLabel", "passwordLabel"];
67
- var propTypes$1 = {
68
- action: PropTypes__default["default"].string.isRequired,
90
+ var _excluded$3 = ["action", "fields", "size", "emailLabel", "passwordLabel", "submitButtonLabel", "withForgotPassword", "forgotPasswordLink", "forgotPasswordLabel"];
91
+ var propTypes$3 = {
92
+ action: PropTypes__default["default"].string,
69
93
  fields: core.PropTypes.fields,
70
94
  size: PropTypes__default["default"].string,
71
- emailLabel: core.PropTypes.message,
72
- passwordLabel: core.PropTypes.message
95
+ emailLabel: core.PropTypes.label,
96
+ passwordLabel: core.PropTypes.label,
97
+ submitButtonLabel: core.PropTypes.label,
98
+ withForgotPassword: PropTypes__default["default"].bool,
99
+ forgotPasswordLink: PropTypes__default["default"].string,
100
+ forgotPasswordLabel: core.PropTypes.label
73
101
  };
74
- var defaultProps$1 = {
102
+ var defaultProps$3 = {
103
+ action: '/login',
75
104
  fields: null,
76
105
  size: 'lg',
77
106
  emailLabel: /*#__PURE__*/React__default["default"].createElement(reactIntl.FormattedMessage, {
@@ -87,16 +116,36 @@ var defaultProps$1 = {
87
116
  "type": 0,
88
117
  "value": "Password"
89
118
  }]
119
+ }),
120
+ submitButtonLabel: /*#__PURE__*/React__default["default"].createElement(reactIntl.FormattedMessage, {
121
+ id: "g6qbbX",
122
+ defaultMessage: [{
123
+ "type": 0,
124
+ "value": "Log in"
125
+ }]
126
+ }),
127
+ withForgotPassword: true,
128
+ forgotPasswordLink: '/forgot-password',
129
+ forgotPasswordLabel: /*#__PURE__*/React__default["default"].createElement(reactIntl.FormattedMessage, {
130
+ id: "ZBNqY2",
131
+ defaultMessage: [{
132
+ "type": 0,
133
+ "value": "Forgot your password?"
134
+ }]
90
135
  })
91
136
  };
92
137
 
93
- var LoginForm = function LoginForm(_ref) {
138
+ var Login = function Login(_ref) {
94
139
  var action = _ref.action,
95
140
  fields = _ref.fields,
96
141
  size = _ref.size,
97
142
  emailLabel = _ref.emailLabel,
98
143
  passwordLabel = _ref.passwordLabel,
99
- props = _objectWithoutProperties__default["default"](_ref, _excluded$1);
144
+ submitButtonLabel = _ref.submitButtonLabel,
145
+ withForgotPassword = _ref.withForgotPassword,
146
+ forgotPasswordLink = _ref.forgotPasswordLink,
147
+ forgotPasswordLabel = _ref.forgotPasswordLabel,
148
+ props = _objectWithoutProperties__default["default"](_ref, _excluded$3);
100
149
 
101
150
  return /*#__PURE__*/React__default["default"].createElement(Form__default["default"], Object.assign({
102
151
  action: action,
@@ -111,30 +160,49 @@ var LoginForm = function LoginForm(_ref) {
111
160
  size: size,
112
161
  label: passwordLabel
113
162
  }],
114
- submitButtonLabel: /*#__PURE__*/React__default["default"].createElement(reactIntl.FormattedMessage, {
115
- id: "g6qbbX",
116
- defaultMessage: [{
117
- "type": 0,
118
- "value": "Log in"
119
- }]
120
- })
163
+ submitButtonLabel: submitButtonLabel,
164
+ actions: withForgotPassword ? /*#__PURE__*/React__default["default"].createElement(reactRouterDom.Link, {
165
+ className: "py-2 px-4",
166
+ to: forgotPasswordLink
167
+ }, forgotPasswordLabel) : null
121
168
  }, props));
122
169
  };
123
170
 
124
- LoginForm.propTypes = propTypes$1;
125
- LoginForm.defaultProps = defaultProps$1;
171
+ Login.propTypes = propTypes$3;
172
+ Login.defaultProps = defaultProps$3;
126
173
 
127
- var _excluded = ["action", "fields", "size", "passwordLabel", "passwordConfirmationLabel"];
128
- var propTypes = {
129
- action: PropTypes__default["default"].string.isRequired,
174
+ var _excluded$2 = ["action", "fields", "size", "nameLabel", "emailLabel", "passwordLabel", "passwordConfirmationLabel", "submitButtonLabel", "withLoginLink", "loginLink", "loginLabel"];
175
+ var propTypes$2 = {
176
+ action: PropTypes__default["default"].string,
130
177
  fields: core.PropTypes.fields,
131
178
  size: PropTypes__default["default"].string,
132
- passwordLabel: core.PropTypes.message,
133
- passwordConfirmationLabel: core.PropTypes.message
179
+ nameLabel: core.PropTypes.label,
180
+ emailLabel: core.PropTypes.label,
181
+ passwordLabel: core.PropTypes.label,
182
+ passwordConfirmationLabel: core.PropTypes.label,
183
+ submitButtonLabel: core.PropTypes.label,
184
+ withLoginLink: PropTypes__default["default"].bool,
185
+ loginLink: PropTypes__default["default"].string,
186
+ loginLabel: core.PropTypes.label
134
187
  };
135
- var defaultProps = {
188
+ var defaultProps$2 = {
189
+ action: '/register',
136
190
  fields: null,
137
191
  size: 'lg',
192
+ nameLabel: /*#__PURE__*/React__default["default"].createElement(reactIntl.FormattedMessage, {
193
+ id: "UUv8FR",
194
+ defaultMessage: [{
195
+ "type": 0,
196
+ "value": "Name"
197
+ }]
198
+ }),
199
+ emailLabel: /*#__PURE__*/React__default["default"].createElement(reactIntl.FormattedMessage, {
200
+ id: "LI0Gz4",
201
+ defaultMessage: [{
202
+ "type": 0,
203
+ "value": "Email"
204
+ }]
205
+ }),
138
206
  passwordLabel: /*#__PURE__*/React__default["default"].createElement(reactIntl.FormattedMessage, {
139
207
  id: "4yfet+",
140
208
  defaultMessage: [{
@@ -143,10 +211,110 @@ var defaultProps = {
143
211
  }]
144
212
  }),
145
213
  passwordConfirmationLabel: /*#__PURE__*/React__default["default"].createElement(reactIntl.FormattedMessage, {
146
- id: "SdtI90",
214
+ id: "VhJUeW",
147
215
  defaultMessage: [{
148
216
  "type": 0,
149
- "value": "Password confirmation"
217
+ "value": "Confirm your password"
218
+ }]
219
+ }),
220
+ submitButtonLabel: /*#__PURE__*/React__default["default"].createElement(reactIntl.FormattedMessage, {
221
+ id: "PQX/ph",
222
+ defaultMessage: [{
223
+ "type": 0,
224
+ "value": "Create account"
225
+ }]
226
+ }),
227
+ withLoginLink: true,
228
+ loginLink: '/forgot-password',
229
+ loginLabel: /*#__PURE__*/React__default["default"].createElement(reactIntl.FormattedMessage, {
230
+ id: "wa783M",
231
+ defaultMessage: [{
232
+ "type": 0,
233
+ "value": "Already have an account? Go to login"
234
+ }]
235
+ })
236
+ };
237
+
238
+ var Register = function Register(_ref) {
239
+ var action = _ref.action,
240
+ fields = _ref.fields,
241
+ size = _ref.size,
242
+ nameLabel = _ref.nameLabel,
243
+ emailLabel = _ref.emailLabel,
244
+ passwordLabel = _ref.passwordLabel,
245
+ passwordConfirmationLabel = _ref.passwordConfirmationLabel,
246
+ submitButtonLabel = _ref.submitButtonLabel,
247
+ withLoginLink = _ref.withLoginLink,
248
+ loginLink = _ref.loginLink,
249
+ loginLabel = _ref.loginLabel,
250
+ props = _objectWithoutProperties__default["default"](_ref, _excluded$2);
251
+
252
+ return /*#__PURE__*/React__default["default"].createElement(Form__default["default"], Object.assign({
253
+ action: action,
254
+ fields: fields || [{
255
+ name: 'name',
256
+ type: 'text',
257
+ size: size,
258
+ label: nameLabel
259
+ }, {
260
+ name: 'email',
261
+ type: 'email',
262
+ size: size,
263
+ label: emailLabel
264
+ }, {
265
+ name: 'password',
266
+ type: 'password',
267
+ size: size,
268
+ label: passwordLabel
269
+ }, {
270
+ name: 'password_confirmation',
271
+ type: 'password',
272
+ size: size,
273
+ label: passwordConfirmationLabel
274
+ }],
275
+ submitButtonLabel: submitButtonLabel,
276
+ actions: withLoginLink ? /*#__PURE__*/React__default["default"].createElement(reactRouterDom.Link, {
277
+ className: "py-2 px-4",
278
+ to: loginLink
279
+ }, loginLabel) : null
280
+ }, props));
281
+ };
282
+
283
+ Register.propTypes = propTypes$2;
284
+ Register.defaultProps = defaultProps$2;
285
+
286
+ var _excluded$1 = ["action", "fields", "size", "passwordLabel", "passwordConfirmationLabel", "submitButtonLabel"];
287
+ var propTypes$1 = {
288
+ action: PropTypes__default["default"].string,
289
+ fields: core.PropTypes.fields,
290
+ size: PropTypes__default["default"].string,
291
+ passwordLabel: core.PropTypes.label,
292
+ passwordConfirmationLabel: core.PropTypes.label,
293
+ submitButtonLabel: core.PropTypes.label
294
+ };
295
+ var defaultProps$1 = {
296
+ action: '/reset-password',
297
+ fields: null,
298
+ size: 'lg',
299
+ passwordLabel: /*#__PURE__*/React__default["default"].createElement(reactIntl.FormattedMessage, {
300
+ id: "4yfet+",
301
+ defaultMessage: [{
302
+ "type": 0,
303
+ "value": "Password"
304
+ }]
305
+ }),
306
+ passwordConfirmationLabel: /*#__PURE__*/React__default["default"].createElement(reactIntl.FormattedMessage, {
307
+ id: "VhJUeW",
308
+ defaultMessage: [{
309
+ "type": 0,
310
+ "value": "Confirm your password"
311
+ }]
312
+ }),
313
+ submitButtonLabel: /*#__PURE__*/React__default["default"].createElement(reactIntl.FormattedMessage, {
314
+ id: "zwks3g",
315
+ defaultMessage: [{
316
+ "type": 0,
317
+ "value": "Save new password"
150
318
  }]
151
319
  })
152
320
  };
@@ -157,7 +325,8 @@ var ResetPassword = function ResetPassword(_ref) {
157
325
  size = _ref.size,
158
326
  passwordLabel = _ref.passwordLabel,
159
327
  passwordConfirmationLabel = _ref.passwordConfirmationLabel,
160
- props = _objectWithoutProperties__default["default"](_ref, _excluded);
328
+ submitButtonLabel = _ref.submitButtonLabel,
329
+ props = _objectWithoutProperties__default["default"](_ref, _excluded$1);
161
330
 
162
331
  return /*#__PURE__*/React__default["default"].createElement(Form__default["default"], Object.assign({
163
332
  action: action,
@@ -172,19 +341,79 @@ var ResetPassword = function ResetPassword(_ref) {
172
341
  size: size,
173
342
  label: passwordConfirmationLabel
174
343
  }],
175
- submitButtonLabel: /*#__PURE__*/React__default["default"].createElement(reactIntl.FormattedMessage, {
176
- id: "zwks3g",
177
- defaultMessage: [{
178
- "type": 0,
179
- "value": "Save new password"
180
- }]
181
- })
344
+ submitButtonLabel: submitButtonLabel
182
345
  }, props));
183
346
  };
184
347
 
185
- ResetPassword.propTypes = propTypes;
186
- ResetPassword.defaultProps = defaultProps;
348
+ ResetPassword.propTypes = propTypes$1;
349
+ ResetPassword.defaultProps = defaultProps$1;
350
+
351
+ var _excluded = ["action", "fields", "explainationLabel", "submitButtonLabel", "size", "withSkipLink", "skipLink", "skipLabel"];
352
+ var propTypes = {
353
+ action: PropTypes__default["default"].string,
354
+ fields: core.PropTypes.fields,
355
+ size: PropTypes__default["default"].string,
356
+ explainationLabel: core.PropTypes.label,
357
+ submitButtonLabel: core.PropTypes.label,
358
+ withSkipLink: PropTypes__default["default"].bool,
359
+ skipLink: PropTypes__default["default"].string,
360
+ skipLabel: core.PropTypes.label
361
+ };
362
+ var defaultProps = {
363
+ action: '/user/two-factor-authentication',
364
+ fields: null,
365
+ size: 'lg',
366
+ explainationLabel: /*#__PURE__*/React__default["default"].createElement(reactIntl.FormattedMessage, {
367
+ id: "zTiC4D",
368
+ defaultMessage: [{
369
+ "type": 0,
370
+ "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."
371
+ }]
372
+ }),
373
+ submitButtonLabel: /*#__PURE__*/React__default["default"].createElement(reactIntl.FormattedMessage, {
374
+ id: "gj67c0",
375
+ defaultMessage: [{
376
+ "type": 0,
377
+ "value": "Enable Two Factor authentication"
378
+ }]
379
+ }),
380
+ withSkipLink: true,
381
+ skipLink: '/home',
382
+ skipLabel: /*#__PURE__*/React__default["default"].createElement(reactIntl.FormattedMessage, {
383
+ id: "li2Qqu",
384
+ defaultMessage: [{
385
+ "type": 0,
386
+ "value": "Skip setup"
387
+ }]
388
+ })
389
+ };
390
+
391
+ var TwoFactor = function TwoFactor(_ref) {
392
+ var action = _ref.action;
393
+ _ref.fields;
394
+ var explainationLabel = _ref.explainationLabel,
395
+ submitButtonLabel = _ref.submitButtonLabel;
396
+ _ref.size;
397
+ var withSkipLink = _ref.withSkipLink,
398
+ skipLink = _ref.skipLink,
399
+ skipLabel = _ref.skipLabel,
400
+ props = _objectWithoutProperties__default["default"](_ref, _excluded);
401
+
402
+ return /*#__PURE__*/React__default["default"].createElement(Form__default["default"], Object.assign({
403
+ action: action,
404
+ submitButtonLabel: submitButtonLabel,
405
+ actions: withSkipLink ? /*#__PURE__*/React__default["default"].createElement(reactRouterDom.Link, {
406
+ className: "py-2 px-4",
407
+ to: skipLink
408
+ }, skipLabel) : null
409
+ }, props), /*#__PURE__*/React__default["default"].createElement("p", null, explainationLabel));
410
+ };
411
+
412
+ TwoFactor.propTypes = propTypes;
413
+ TwoFactor.defaultProps = defaultProps;
187
414
 
188
415
  exports.ForgotPassword = ForgotPassword;
189
- exports.Login = LoginForm;
416
+ exports.Login = Login;
417
+ exports.Register = Register;
190
418
  exports.ResetPassword = ResetPassword;
419
+ 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.236",
3
+ "version": "1.0.0-alpha.240",
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
- "@panneau/core": "^1.0.0-alpha.236",
49
- "@panneau/form": "^1.0.0-alpha.236",
49
+ "@panneau/core": "^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": "ac8add5d37f0c2439d9b3726d052f2698ee1ea3b"
60
+ "gitHead": "de9613d3f28c586222bfeece6e88cc9ecf59485f"
59
61
  }