@reachfive/identity-ui 1.13.0 → 1.16.0
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.
- package/CHANGELOG.md +59 -17
- package/cjs/identity-ui.js +628 -83
- package/es/identity-ui.js +628 -83
- package/package.json +3 -3
- package/umd/identity-ui.js +14917 -12008
- package/umd/identity-ui.min.js +1 -1
package/cjs/identity-ui.js
CHANGED
|
@@ -18,8 +18,8 @@ var classes = _interopDefault(require('classnames'));
|
|
|
18
18
|
var remarkable = require('remarkable');
|
|
19
19
|
var validator = require('validator');
|
|
20
20
|
var validator__default = _interopDefault(validator);
|
|
21
|
-
var lodashEs = require('lodash-es');
|
|
22
21
|
var libphonenumber = require('libphonenumber-js');
|
|
22
|
+
var lodashEs = require('lodash-es');
|
|
23
23
|
var charInfo = require('char-info');
|
|
24
24
|
var zxcvbn = _interopDefault(require('@reachfive/zxcvbn'));
|
|
25
25
|
|
|
@@ -4077,10 +4077,15 @@ function multiViewWidget(_ref3) {
|
|
|
4077
4077
|
}), _temp;
|
|
4078
4078
|
}
|
|
4079
4079
|
|
|
4080
|
-
/* Returns whether a form value has been set with a valid value
|
|
4080
|
+
/* Returns whether a form value has been set with a valid value.
|
|
4081
|
+
* If the user's input has been enriched as an object, raw input is expected
|
|
4082
|
+
* to be in a raw property field (named 'raw' by default).
|
|
4083
|
+
*/
|
|
4081
4084
|
|
|
4082
4085
|
function isValued(v) {
|
|
4083
|
-
|
|
4086
|
+
var rawProperty = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'raw';
|
|
4087
|
+
var unwrap = isObject(v) ? v[rawProperty] : v;
|
|
4088
|
+
return unwrap !== null && unwrap !== undefined && unwrap !== '' && !Number.isNaN(unwrap) && (Array.isArray(unwrap) ? unwrap.length > 0 : true);
|
|
4084
4089
|
}
|
|
4085
4090
|
function formatISO8601Date(year, month, day) {
|
|
4086
4091
|
if (isValued(year) && isValued(month) && isValued(day)) {
|
|
@@ -4089,6 +4094,15 @@ function formatISO8601Date(year, month, day) {
|
|
|
4089
4094
|
|
|
4090
4095
|
return null;
|
|
4091
4096
|
}
|
|
4097
|
+
function specializeIdentifierData(data) {
|
|
4098
|
+
return !!data.identifier ? _objectSpread2(_objectSpread2({}, data), {}, {
|
|
4099
|
+
identifier: undefined
|
|
4100
|
+
}, /@/.test(data.identifier) ? {
|
|
4101
|
+
email: data.identifier
|
|
4102
|
+
} : {
|
|
4103
|
+
phoneNumber: data.identifier.replace(/\s+/g, '')
|
|
4104
|
+
}) : data;
|
|
4105
|
+
}
|
|
4092
4106
|
|
|
4093
4107
|
var CompoundValidator = /*#__PURE__*/function () {
|
|
4094
4108
|
function CompoundValidator(current, next) {
|
|
@@ -4127,7 +4141,9 @@ var Validator = /*#__PURE__*/function () {
|
|
|
4127
4141
|
_classCallCheck(this, Validator);
|
|
4128
4142
|
|
|
4129
4143
|
this.rule = rule;
|
|
4130
|
-
this.hint = hint
|
|
4144
|
+
this.hint = !isFunction(hint) ? function (_) {
|
|
4145
|
+
return hint;
|
|
4146
|
+
} : hint;
|
|
4131
4147
|
this.parameters = parameters;
|
|
4132
4148
|
}
|
|
4133
4149
|
|
|
@@ -4136,10 +4152,13 @@ var Validator = /*#__PURE__*/function () {
|
|
|
4136
4152
|
value: function create(i18n) {
|
|
4137
4153
|
var _this = this;
|
|
4138
4154
|
|
|
4139
|
-
var errorMessage =
|
|
4155
|
+
var errorMessage = function errorMessage(v) {
|
|
4156
|
+
return i18n("validation.".concat(_this.hint(v)), _this.parameters);
|
|
4157
|
+
};
|
|
4158
|
+
|
|
4140
4159
|
return function (value, ctx) {
|
|
4141
4160
|
return !_this.rule(value, ctx) && {
|
|
4142
|
-
error: errorMessage
|
|
4161
|
+
error: errorMessage(value)
|
|
4143
4162
|
};
|
|
4144
4163
|
};
|
|
4145
4164
|
}
|
|
@@ -8812,6 +8831,8 @@ var createField = function createField(_ref) {
|
|
|
8812
8831
|
return !isEmpty(x) ? x : null;
|
|
8813
8832
|
}
|
|
8814
8833
|
} : _ref$format,
|
|
8834
|
+
_ref$rawProperty = _ref.rawProperty,
|
|
8835
|
+
rawProperty = _ref$rawProperty === void 0 ? 'raw' : _ref$rawProperty,
|
|
8815
8836
|
component = _ref.component,
|
|
8816
8837
|
_ref$extendedParams = _ref.extendedParams,
|
|
8817
8838
|
extendedParams = _ref$extendedParams === void 0 ? {} : _ref$extendedParams;
|
|
@@ -8845,7 +8866,7 @@ var createField = function createField(_ref) {
|
|
|
8845
8866
|
},
|
|
8846
8867
|
initialize: function initialize(model) {
|
|
8847
8868
|
var modelValue = mapping.bind(model);
|
|
8848
|
-
var initValue = isValued(modelValue) ? modelValue : defaultValue;
|
|
8869
|
+
var initValue = isValued(modelValue, rawProperty) ? modelValue : defaultValue;
|
|
8849
8870
|
return {
|
|
8850
8871
|
value: format.bind(initValue),
|
|
8851
8872
|
isDirty: false
|
|
@@ -9112,6 +9133,310 @@ function checkboxField(config) {
|
|
|
9112
9133
|
}));
|
|
9113
9134
|
}
|
|
9114
9135
|
|
|
9136
|
+
/*
|
|
9137
|
+
* All possible Identifier data is in the `value` prop, they should all be preserved when the type changes.
|
|
9138
|
+
* {
|
|
9139
|
+
* raw: string,
|
|
9140
|
+
* type: 'tel' | 'email' | 'other',
|
|
9141
|
+
* country: string,
|
|
9142
|
+
* formatted: string,
|
|
9143
|
+
* isValid: boolean,
|
|
9144
|
+
* }
|
|
9145
|
+
*/
|
|
9146
|
+
|
|
9147
|
+
function specializeRawIdentifier(inputValue) {
|
|
9148
|
+
var telCall = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : function (_) {
|
|
9149
|
+
return undefined;
|
|
9150
|
+
};
|
|
9151
|
+
var emailCall = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : function (_) {
|
|
9152
|
+
return undefined;
|
|
9153
|
+
};
|
|
9154
|
+
var otherCall = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : function (_) {
|
|
9155
|
+
return undefined;
|
|
9156
|
+
};
|
|
9157
|
+
|
|
9158
|
+
if (/^\+?[0-9]+/.test(inputValue)) {
|
|
9159
|
+
return _objectSpread2(_objectSpread2({
|
|
9160
|
+
raw: inputValue
|
|
9161
|
+
}, telCall(inputValue)), {}, {
|
|
9162
|
+
type: 'tel'
|
|
9163
|
+
});
|
|
9164
|
+
} else if (/@/.test(inputValue)) {
|
|
9165
|
+
return _objectSpread2(_objectSpread2({
|
|
9166
|
+
raw: inputValue
|
|
9167
|
+
}, emailCall(inputValue)), {}, {
|
|
9168
|
+
type: 'email'
|
|
9169
|
+
});
|
|
9170
|
+
} else {
|
|
9171
|
+
return _objectSpread2(_objectSpread2({
|
|
9172
|
+
raw: inputValue
|
|
9173
|
+
}, otherCall(inputValue)), {}, {
|
|
9174
|
+
type: 'text'
|
|
9175
|
+
});
|
|
9176
|
+
}
|
|
9177
|
+
}
|
|
9178
|
+
|
|
9179
|
+
function specializeRefinedIdentifier(identifier) {
|
|
9180
|
+
var telCall = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : function (x) {
|
|
9181
|
+
return x;
|
|
9182
|
+
};
|
|
9183
|
+
var emailCall = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : function (x) {
|
|
9184
|
+
return x;
|
|
9185
|
+
};
|
|
9186
|
+
var otherCall = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : function (x) {
|
|
9187
|
+
return x;
|
|
9188
|
+
};
|
|
9189
|
+
if (identifier.type === 'tel') return telCall(identifier);else if (identifier.type === 'email') return emailCall(identifier);else return otherCall(identifier);
|
|
9190
|
+
}
|
|
9191
|
+
|
|
9192
|
+
var IdentifierField = /*#__PURE__*/function (_React$Component) {
|
|
9193
|
+
_inherits(IdentifierField, _React$Component);
|
|
9194
|
+
|
|
9195
|
+
var _super = _createSuper(IdentifierField);
|
|
9196
|
+
|
|
9197
|
+
function IdentifierField() {
|
|
9198
|
+
var _this;
|
|
9199
|
+
|
|
9200
|
+
_classCallCheck(this, IdentifierField);
|
|
9201
|
+
|
|
9202
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
9203
|
+
args[_key] = arguments[_key];
|
|
9204
|
+
}
|
|
9205
|
+
|
|
9206
|
+
_this = _super.call.apply(_super, [this].concat(args));
|
|
9207
|
+
|
|
9208
|
+
_defineProperty(_assertThisInitialized(_this), "asYouType", function (inputValue) {
|
|
9209
|
+
var country = _this.props.value.country;
|
|
9210
|
+
var phone = new libphonenumber.AsYouType(country).input(inputValue);
|
|
9211
|
+
var formatted = libphonenumber.format(phone, country, 'International');
|
|
9212
|
+
var isValid = libphonenumber.isValidNumber(phone, country);
|
|
9213
|
+
return {
|
|
9214
|
+
country: country,
|
|
9215
|
+
formatted: formatted,
|
|
9216
|
+
isValid: isValid,
|
|
9217
|
+
raw: phone
|
|
9218
|
+
};
|
|
9219
|
+
});
|
|
9220
|
+
|
|
9221
|
+
return _this;
|
|
9222
|
+
}
|
|
9223
|
+
|
|
9224
|
+
_createClass(IdentifierField, [{
|
|
9225
|
+
key: "componentDidMount",
|
|
9226
|
+
value: function componentDidMount() {
|
|
9227
|
+
var _this$props$value = this.props.value,
|
|
9228
|
+
userInput = _this$props$value.userInput,
|
|
9229
|
+
country = _this$props$value.country;
|
|
9230
|
+
|
|
9231
|
+
try {
|
|
9232
|
+
var parsed = libphonenumber.parse(userInput, country);
|
|
9233
|
+
var phoneValue = country === parsed.country ? libphonenumber.format(parsed, 'National') : userInput;
|
|
9234
|
+
this.asYouType(phoneValue);
|
|
9235
|
+
} catch (e) {}
|
|
9236
|
+
}
|
|
9237
|
+
}, {
|
|
9238
|
+
key: "componentWillUnmount",
|
|
9239
|
+
value: function componentWillUnmount() {
|
|
9240
|
+
this.unmounted = true;
|
|
9241
|
+
}
|
|
9242
|
+
}, {
|
|
9243
|
+
key: "render",
|
|
9244
|
+
value: function render() {
|
|
9245
|
+
var _this2 = this;
|
|
9246
|
+
|
|
9247
|
+
var _this$props = this.props,
|
|
9248
|
+
path = _this$props.path,
|
|
9249
|
+
value = _this$props.value,
|
|
9250
|
+
_this$props$validatio = _this$props.validation,
|
|
9251
|
+
validation = _this$props$validatio === void 0 ? {} : _this$props$validatio,
|
|
9252
|
+
inputId = _this$props.inputId,
|
|
9253
|
+
_this$props$required = _this$props.required,
|
|
9254
|
+
required = _this$props$required === void 0 ? true : _this$props$required,
|
|
9255
|
+
label = _this$props.label,
|
|
9256
|
+
_this$props$placehold = _this$props.placeholder,
|
|
9257
|
+
placeholder = _this$props$placehold === void 0 ? label : _this$props$placehold,
|
|
9258
|
+
readOnly = _this$props.readOnly;
|
|
9259
|
+
return /*#__PURE__*/React__default.createElement(FormGroup, _extends({
|
|
9260
|
+
inputId: inputId,
|
|
9261
|
+
labelText: label
|
|
9262
|
+
}, pick(validation, 'error'), {
|
|
9263
|
+
showLabel: this.props.showLabel
|
|
9264
|
+
}), /*#__PURE__*/React__default.createElement(Input, {
|
|
9265
|
+
id: inputId,
|
|
9266
|
+
name: path,
|
|
9267
|
+
type: value.type,
|
|
9268
|
+
value: value.raw || '',
|
|
9269
|
+
placeholder: placeholder,
|
|
9270
|
+
title: label,
|
|
9271
|
+
required: required,
|
|
9272
|
+
readOnly: readOnly,
|
|
9273
|
+
hasError: !!validation.error,
|
|
9274
|
+
onChange: function onChange(event) {
|
|
9275
|
+
return _this2.props.onChange({
|
|
9276
|
+
value: _objectSpread2(_objectSpread2({}, _this2.props.value), specializeRawIdentifier(event.target.value, _this2.asYouType))
|
|
9277
|
+
});
|
|
9278
|
+
},
|
|
9279
|
+
onBlur: function onBlur() {
|
|
9280
|
+
return _this2.props.onChange({
|
|
9281
|
+
isDirty: true
|
|
9282
|
+
});
|
|
9283
|
+
},
|
|
9284
|
+
"data-testid": path
|
|
9285
|
+
}));
|
|
9286
|
+
}
|
|
9287
|
+
}]);
|
|
9288
|
+
|
|
9289
|
+
return IdentifierField;
|
|
9290
|
+
}(React__default.Component);
|
|
9291
|
+
|
|
9292
|
+
function identifierField(props, config) {
|
|
9293
|
+
return createField(_objectSpread2(_objectSpread2({}, props), {}, {
|
|
9294
|
+
key: 'identifier',
|
|
9295
|
+
label: 'identifier',
|
|
9296
|
+
format: {
|
|
9297
|
+
bind: function bind(x) {
|
|
9298
|
+
return specializeRawIdentifier(x, function (_) {
|
|
9299
|
+
return {
|
|
9300
|
+
country: config.countryCode,
|
|
9301
|
+
isValid: true
|
|
9302
|
+
};
|
|
9303
|
+
}, function (_) {
|
|
9304
|
+
return {
|
|
9305
|
+
country: config.countryCode,
|
|
9306
|
+
isValid: true
|
|
9307
|
+
};
|
|
9308
|
+
}, function (_) {
|
|
9309
|
+
return {
|
|
9310
|
+
country: config.countryCode,
|
|
9311
|
+
isValid: true
|
|
9312
|
+
};
|
|
9313
|
+
});
|
|
9314
|
+
},
|
|
9315
|
+
unbind: function unbind(x) {
|
|
9316
|
+
return specializeRefinedIdentifier(x, function (v) {
|
|
9317
|
+
return v.formatted || v.raw;
|
|
9318
|
+
}, function (v) {
|
|
9319
|
+
return v.raw;
|
|
9320
|
+
}, function (v) {
|
|
9321
|
+
return v.raw;
|
|
9322
|
+
});
|
|
9323
|
+
}
|
|
9324
|
+
},
|
|
9325
|
+
validator: new Validator({
|
|
9326
|
+
rule: function rule(value) {
|
|
9327
|
+
return specializeRefinedIdentifier(value, function (v) {
|
|
9328
|
+
return v.isValid;
|
|
9329
|
+
}, function (v) {
|
|
9330
|
+
return email.rule(v.raw);
|
|
9331
|
+
}, function (_) {
|
|
9332
|
+
return false;
|
|
9333
|
+
});
|
|
9334
|
+
},
|
|
9335
|
+
hint: function hint(value) {
|
|
9336
|
+
return specializeRefinedIdentifier(value, function (_) {
|
|
9337
|
+
return 'phone';
|
|
9338
|
+
}, function (_) {
|
|
9339
|
+
return 'email';
|
|
9340
|
+
}, function (_) {
|
|
9341
|
+
return 'identifier';
|
|
9342
|
+
});
|
|
9343
|
+
}
|
|
9344
|
+
}),
|
|
9345
|
+
component: IdentifierField
|
|
9346
|
+
}));
|
|
9347
|
+
}
|
|
9348
|
+
|
|
9349
|
+
var ReCaptcha = function ReCaptcha() {
|
|
9350
|
+
_classCallCheck(this, ReCaptcha);
|
|
9351
|
+
};
|
|
9352
|
+
|
|
9353
|
+
_defineProperty(ReCaptcha, "getRecaptchaToken", /*#__PURE__*/function () {
|
|
9354
|
+
var _ref = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee(siteKey, action) {
|
|
9355
|
+
return regeneratorRuntime.wrap(function _callee$(_context) {
|
|
9356
|
+
while (1) {
|
|
9357
|
+
switch (_context.prev = _context.next) {
|
|
9358
|
+
case 0:
|
|
9359
|
+
_context.next = 2;
|
|
9360
|
+
return window.grecaptcha.execute(siteKey, {
|
|
9361
|
+
action: action
|
|
9362
|
+
});
|
|
9363
|
+
|
|
9364
|
+
case 2:
|
|
9365
|
+
return _context.abrupt("return", _context.sent);
|
|
9366
|
+
|
|
9367
|
+
case 3:
|
|
9368
|
+
case "end":
|
|
9369
|
+
return _context.stop();
|
|
9370
|
+
}
|
|
9371
|
+
}
|
|
9372
|
+
}, _callee);
|
|
9373
|
+
}));
|
|
9374
|
+
|
|
9375
|
+
return function (_x, _x2) {
|
|
9376
|
+
return _ref.apply(this, arguments);
|
|
9377
|
+
};
|
|
9378
|
+
}());
|
|
9379
|
+
|
|
9380
|
+
_defineProperty(ReCaptcha, "handle", /*#__PURE__*/function () {
|
|
9381
|
+
var _ref2 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2(data, conf, callback, action) {
|
|
9382
|
+
var captchaToken;
|
|
9383
|
+
return regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
9384
|
+
while (1) {
|
|
9385
|
+
switch (_context2.prev = _context2.next) {
|
|
9386
|
+
case 0:
|
|
9387
|
+
if (!conf.recaptcha_enabled) {
|
|
9388
|
+
_context2.next = 13;
|
|
9389
|
+
break;
|
|
9390
|
+
}
|
|
9391
|
+
|
|
9392
|
+
_context2.prev = 1;
|
|
9393
|
+
_context2.next = 4;
|
|
9394
|
+
return ReCaptcha.getRecaptchaToken(conf.recaptcha_site_key, action);
|
|
9395
|
+
|
|
9396
|
+
case 4:
|
|
9397
|
+
captchaToken = _context2.sent;
|
|
9398
|
+
return _context2.abrupt("return", callback(_objectSpread2(_objectSpread2({}, data), {}, {
|
|
9399
|
+
captchaToken: captchaToken
|
|
9400
|
+
})));
|
|
9401
|
+
|
|
9402
|
+
case 8:
|
|
9403
|
+
_context2.prev = 8;
|
|
9404
|
+
_context2.t0 = _context2["catch"](1);
|
|
9405
|
+
return _context2.abrupt("return", Promise.reject({
|
|
9406
|
+
errorUserMsg: "Error recaptcha",
|
|
9407
|
+
errorMessageKey: "recaptcha.error"
|
|
9408
|
+
}));
|
|
9409
|
+
|
|
9410
|
+
case 11:
|
|
9411
|
+
_context2.next = 14;
|
|
9412
|
+
break;
|
|
9413
|
+
|
|
9414
|
+
case 13:
|
|
9415
|
+
return _context2.abrupt("return", callback(data));
|
|
9416
|
+
|
|
9417
|
+
case 14:
|
|
9418
|
+
case "end":
|
|
9419
|
+
return _context2.stop();
|
|
9420
|
+
}
|
|
9421
|
+
}
|
|
9422
|
+
}, _callee2, null, [[1, 8]]);
|
|
9423
|
+
}));
|
|
9424
|
+
|
|
9425
|
+
return function (_x3, _x4, _x5, _x6) {
|
|
9426
|
+
return _ref2.apply(this, arguments);
|
|
9427
|
+
};
|
|
9428
|
+
}());
|
|
9429
|
+
function importGoogleRecaptchaScript(site_key) {
|
|
9430
|
+
var script = document.createElement("script");
|
|
9431
|
+
script.src = "https://www.google.com/recaptcha/api.js?render=" + site_key;
|
|
9432
|
+
document.body.appendChild(script);
|
|
9433
|
+
}
|
|
9434
|
+
function extractCaptchaTokenFromData(data) {
|
|
9435
|
+
var token = data.captchaToken;
|
|
9436
|
+
delete data.captchaToken;
|
|
9437
|
+
return token;
|
|
9438
|
+
}
|
|
9439
|
+
|
|
9115
9440
|
function _templateObject$7() {
|
|
9116
9441
|
var data = _taggedTemplateLiteral(["\n margin-bottom: ", "px;\n text-align: right;\n ", ";\n"]);
|
|
9117
9442
|
|
|
@@ -9129,19 +9454,22 @@ var ForgotPasswordWrapper = withTheme(styled__default.div(_templateObject$7(), f
|
|
|
9129
9454
|
var LoginForm = createForm({
|
|
9130
9455
|
prefix: 'r5-login-',
|
|
9131
9456
|
fields: function fields(_ref) {
|
|
9132
|
-
var _ref$
|
|
9133
|
-
|
|
9457
|
+
var _ref$showIdentifier = _ref.showIdentifier,
|
|
9458
|
+
showIdentifier = _ref$showIdentifier === void 0 ? true : _ref$showIdentifier,
|
|
9134
9459
|
showRememberMe = _ref.showRememberMe,
|
|
9135
9460
|
canShowPassword = _ref.canShowPassword,
|
|
9136
9461
|
showForgotPassword = _ref.showForgotPassword,
|
|
9137
|
-
|
|
9138
|
-
i18n = _ref.i18n
|
|
9139
|
-
|
|
9462
|
+
defaultIdentifier = _ref.defaultIdentifier,
|
|
9463
|
+
i18n = _ref.i18n,
|
|
9464
|
+
config = _ref.config;
|
|
9465
|
+
return [showIdentifier && config.sms ? identifierField({
|
|
9466
|
+
defaultValue: defaultIdentifier
|
|
9467
|
+
}, config) : simpleField({
|
|
9140
9468
|
key: 'email',
|
|
9141
9469
|
label: 'email',
|
|
9142
9470
|
type: 'email',
|
|
9143
9471
|
autoComplete: 'email',
|
|
9144
|
-
defaultValue:
|
|
9472
|
+
defaultValue: defaultIdentifier,
|
|
9145
9473
|
validator: email
|
|
9146
9474
|
}), simplePasswordField({
|
|
9147
9475
|
key: 'password',
|
|
@@ -9180,9 +9508,11 @@ var LoginView = /*#__PURE__*/function (_React$Component) {
|
|
|
9180
9508
|
|
|
9181
9509
|
_this = _super.call.apply(_super, [this].concat(args));
|
|
9182
9510
|
|
|
9183
|
-
_defineProperty(_assertThisInitialized(_this), "
|
|
9184
|
-
|
|
9185
|
-
|
|
9511
|
+
_defineProperty(_assertThisInitialized(_this), "callback", function (data) {
|
|
9512
|
+
var specializedData = specializeIdentifierData(data);
|
|
9513
|
+
return _this.props.apiClient.loginWithPassword(_objectSpread2(_objectSpread2({}, specializedData), {}, {
|
|
9514
|
+
captchaToken: data.captchaToken,
|
|
9515
|
+
auth: _objectSpread2(_objectSpread2({}, specializedData.auth), _this.props.auth)
|
|
9186
9516
|
}));
|
|
9187
9517
|
});
|
|
9188
9518
|
|
|
@@ -9190,14 +9520,21 @@ var LoginView = /*#__PURE__*/function (_React$Component) {
|
|
|
9190
9520
|
}
|
|
9191
9521
|
|
|
9192
9522
|
_createClass(LoginView, [{
|
|
9523
|
+
key: "componentDidMount",
|
|
9524
|
+
value: function componentDidMount() {
|
|
9525
|
+
importGoogleRecaptchaScript(this.props.recaptcha_site_key);
|
|
9526
|
+
}
|
|
9527
|
+
}, {
|
|
9193
9528
|
key: "render",
|
|
9194
9529
|
value: function render() {
|
|
9530
|
+
var _this2 = this;
|
|
9531
|
+
|
|
9195
9532
|
var _this$props = this.props,
|
|
9196
9533
|
socialProviders = _this$props.socialProviders,
|
|
9197
9534
|
_this$props$session = _this$props.session,
|
|
9198
9535
|
session = _this$props$session === void 0 ? {} : _this$props$session,
|
|
9199
9536
|
i18n = _this$props.i18n;
|
|
9200
|
-
var
|
|
9537
|
+
var defaultIdentifier = session.lastLoginType === 'password' ? session.email : null;
|
|
9201
9538
|
return /*#__PURE__*/React__default.createElement("div", null, /*#__PURE__*/React__default.createElement(Heading, null, i18n('login.title')), socialProviders && socialProviders.length > 0 && /*#__PURE__*/React__default.createElement(SocialButtons$1, {
|
|
9202
9539
|
providers: socialProviders,
|
|
9203
9540
|
auth: this.props.auth,
|
|
@@ -9209,8 +9546,11 @@ var LoginView = /*#__PURE__*/function (_React$Component) {
|
|
|
9209
9546
|
showRememberMe: this.props.showRememberMe,
|
|
9210
9547
|
showForgotPassword: this.props.allowForgotPassword,
|
|
9211
9548
|
canShowPassword: this.props.canShowPassword,
|
|
9212
|
-
|
|
9213
|
-
handler:
|
|
9549
|
+
defaultIdentifier: defaultIdentifier,
|
|
9550
|
+
handler: function handler(data) {
|
|
9551
|
+
return ReCaptcha.handle(data, _this2.props, _this2.callback, "login");
|
|
9552
|
+
},
|
|
9553
|
+
config: this.props.config
|
|
9214
9554
|
}), this.props.allowSignup && /*#__PURE__*/React__default.createElement(Alternative, null, /*#__PURE__*/React__default.createElement("span", null, i18n('login.signupLinkPrefix')), "\xA0", /*#__PURE__*/React__default.createElement(Link, {
|
|
9215
9555
|
target: "signup"
|
|
9216
9556
|
}, i18n('login.signupLink'))));
|
|
@@ -9392,15 +9732,18 @@ var WebAuthnSignupViewButtons = styled__default(function (_ref3) {
|
|
|
9392
9732
|
var LoginWithWebAuthnForm = createForm({
|
|
9393
9733
|
prefix: 'r5-login-',
|
|
9394
9734
|
fields: function fields(_ref) {
|
|
9395
|
-
var _ref$
|
|
9396
|
-
|
|
9397
|
-
|
|
9398
|
-
|
|
9735
|
+
var _ref$showIdentifier = _ref.showIdentifier,
|
|
9736
|
+
showIdentifier = _ref$showIdentifier === void 0 ? true : _ref$showIdentifier,
|
|
9737
|
+
defaultIdentifier = _ref.defaultIdentifier,
|
|
9738
|
+
config = _ref.config;
|
|
9739
|
+
return [showIdentifier && config.sms ? identifierField({
|
|
9740
|
+
defaultValue: defaultIdentifier
|
|
9741
|
+
}, config) : simpleField({
|
|
9399
9742
|
key: 'email',
|
|
9400
9743
|
label: 'email',
|
|
9401
9744
|
type: 'email',
|
|
9402
9745
|
autoComplete: 'email',
|
|
9403
|
-
defaultValue:
|
|
9746
|
+
defaultValue: defaultIdentifier,
|
|
9404
9747
|
validator: email
|
|
9405
9748
|
})];
|
|
9406
9749
|
},
|
|
@@ -9424,14 +9767,17 @@ var LoginWithWebAuthnView = /*#__PURE__*/function (_React$Component) {
|
|
|
9424
9767
|
_this = _super.call.apply(_super, [this].concat(args));
|
|
9425
9768
|
|
|
9426
9769
|
_defineProperty(_assertThisInitialized(_this), "handleWebAuthnLogin", function (data) {
|
|
9427
|
-
|
|
9428
|
-
|
|
9770
|
+
var specializedData = specializeIdentifierData(data);
|
|
9771
|
+
return _this.props.apiClient.loginWithWebAuthn(_objectSpread2(_objectSpread2({}, specializedData), {}, {
|
|
9772
|
+
auth: _objectSpread2(_objectSpread2({}, specializedData.auth), _this.props.auth)
|
|
9429
9773
|
}));
|
|
9430
9774
|
});
|
|
9431
9775
|
|
|
9432
9776
|
_defineProperty(_assertThisInitialized(_this), "redirectToPasswordLoginView", function (data) {
|
|
9777
|
+
var username = data.identifier || data.email;
|
|
9778
|
+
|
|
9433
9779
|
_this.props.goTo('login-with-password', {
|
|
9434
|
-
username:
|
|
9780
|
+
username: username
|
|
9435
9781
|
});
|
|
9436
9782
|
});
|
|
9437
9783
|
|
|
@@ -9446,7 +9792,7 @@ var LoginWithWebAuthnView = /*#__PURE__*/function (_React$Component) {
|
|
|
9446
9792
|
_this$props$session = _this$props.session,
|
|
9447
9793
|
session = _this$props$session === void 0 ? {} : _this$props$session,
|
|
9448
9794
|
i18n = _this$props.i18n;
|
|
9449
|
-
var
|
|
9795
|
+
var defaultIdentifier = session.lastLoginType === 'password' ? session.email : null;
|
|
9450
9796
|
|
|
9451
9797
|
var webAuthnButtons = function webAuthnButtons(disabled, handleClick) {
|
|
9452
9798
|
return /*#__PURE__*/React__default.createElement(WebAuthnLoginViewButtons, {
|
|
@@ -9464,10 +9810,11 @@ var LoginWithWebAuthnView = /*#__PURE__*/function (_React$Component) {
|
|
|
9464
9810
|
text: i18n('or')
|
|
9465
9811
|
}), /*#__PURE__*/React__default.createElement(LoginWithWebAuthnForm, {
|
|
9466
9812
|
showLabels: this.props.showLabels,
|
|
9467
|
-
|
|
9813
|
+
defaultIdentifier: defaultIdentifier,
|
|
9468
9814
|
handler: this.handleWebAuthnLogin,
|
|
9469
9815
|
redirect: this.redirectToPasswordLoginView,
|
|
9470
|
-
webAuthnButtons: webAuthnButtons
|
|
9816
|
+
webAuthnButtons: webAuthnButtons,
|
|
9817
|
+
config: this.props.config
|
|
9471
9818
|
}), this.props.allowSignup && /*#__PURE__*/React__default.createElement(Alternative, null, /*#__PURE__*/React__default.createElement("span", null, i18n('login.signupLinkPrefix')), "\xA0", /*#__PURE__*/React__default.createElement(Link, {
|
|
9472
9819
|
target: "signup"
|
|
9473
9820
|
}, i18n('login.signupLink'))));
|
|
@@ -9498,8 +9845,13 @@ var LoginWithPasswordForm = createForm({
|
|
|
9498
9845
|
showRememberMe = _ref.showRememberMe,
|
|
9499
9846
|
canShowPassword = _ref.canShowPassword,
|
|
9500
9847
|
showForgotPassword = _ref.showForgotPassword,
|
|
9501
|
-
i18n = _ref.i18n
|
|
9502
|
-
|
|
9848
|
+
i18n = _ref.i18n,
|
|
9849
|
+
config = _ref.config;
|
|
9850
|
+
return [config.sms ? identifierField({
|
|
9851
|
+
key: 'identifier',
|
|
9852
|
+
defaultValue: username,
|
|
9853
|
+
readOnly: true
|
|
9854
|
+
}, config) : simpleField({
|
|
9503
9855
|
key: 'email',
|
|
9504
9856
|
label: 'email',
|
|
9505
9857
|
type: 'email',
|
|
@@ -9543,9 +9895,11 @@ var LoginView$1 = /*#__PURE__*/function (_React$Component) {
|
|
|
9543
9895
|
|
|
9544
9896
|
_this = _super.call.apply(_super, [this].concat(args));
|
|
9545
9897
|
|
|
9546
|
-
_defineProperty(_assertThisInitialized(_this), "
|
|
9547
|
-
|
|
9548
|
-
|
|
9898
|
+
_defineProperty(_assertThisInitialized(_this), "callback", function (data) {
|
|
9899
|
+
var specializedData = specializeIdentifierData(data);
|
|
9900
|
+
return _this.props.apiClient.loginWithPassword(_objectSpread2(_objectSpread2({}, specializedData), {}, {
|
|
9901
|
+
captchaToken: data.captchaToken,
|
|
9902
|
+
auth: _objectSpread2(_objectSpread2({}, specializedData.auth), _this.props.auth)
|
|
9549
9903
|
}));
|
|
9550
9904
|
});
|
|
9551
9905
|
|
|
@@ -9553,8 +9907,15 @@ var LoginView$1 = /*#__PURE__*/function (_React$Component) {
|
|
|
9553
9907
|
}
|
|
9554
9908
|
|
|
9555
9909
|
_createClass(LoginView, [{
|
|
9910
|
+
key: "componentDidMount",
|
|
9911
|
+
value: function componentDidMount() {
|
|
9912
|
+
importGoogleRecaptchaScript(this.props.recaptcha_site_key);
|
|
9913
|
+
}
|
|
9914
|
+
}, {
|
|
9556
9915
|
key: "render",
|
|
9557
9916
|
value: function render() {
|
|
9917
|
+
var _this2 = this;
|
|
9918
|
+
|
|
9558
9919
|
var i18n = this.props.i18n;
|
|
9559
9920
|
return /*#__PURE__*/React__default.createElement("div", null, /*#__PURE__*/React__default.createElement(Heading, null, i18n('login.title')), /*#__PURE__*/React__default.createElement(LoginWithPasswordForm, {
|
|
9560
9921
|
username: this.props.username,
|
|
@@ -9562,7 +9923,10 @@ var LoginView$1 = /*#__PURE__*/function (_React$Component) {
|
|
|
9562
9923
|
showRememberMe: this.props.showRememberMe,
|
|
9563
9924
|
showForgotPassword: this.props.allowForgotPassword,
|
|
9564
9925
|
canShowPassword: this.props.canShowPassword,
|
|
9565
|
-
handler:
|
|
9926
|
+
handler: function handler(data) {
|
|
9927
|
+
return ReCaptcha.handle(data, _this2.props, _this2.callback, "login");
|
|
9928
|
+
},
|
|
9929
|
+
config: this.props.config
|
|
9566
9930
|
}), /*#__PURE__*/React__default.createElement(Alternative, null, /*#__PURE__*/React__default.createElement(Link, {
|
|
9567
9931
|
target: "login-with-web-authn"
|
|
9568
9932
|
}, i18n('login.password.userAnotherIdentifier'))));
|
|
@@ -10182,7 +10546,7 @@ var PhoneNumberField = /*#__PURE__*/function (_React$Component) {
|
|
|
10182
10546
|
_this.props.onChange({
|
|
10183
10547
|
value: {
|
|
10184
10548
|
country: country,
|
|
10185
|
-
|
|
10549
|
+
raw: phone,
|
|
10186
10550
|
formatted: formatted,
|
|
10187
10551
|
isValid: isValid
|
|
10188
10552
|
}
|
|
@@ -10196,12 +10560,12 @@ var PhoneNumberField = /*#__PURE__*/function (_React$Component) {
|
|
|
10196
10560
|
key: "componentDidMount",
|
|
10197
10561
|
value: function componentDidMount() {
|
|
10198
10562
|
var _this$props$value = this.props.value,
|
|
10199
|
-
|
|
10563
|
+
raw = _this$props$value.raw,
|
|
10200
10564
|
country = _this$props$value.country;
|
|
10201
10565
|
|
|
10202
10566
|
try {
|
|
10203
|
-
var parsed = libphonenumber.parse(
|
|
10204
|
-
var phoneValue = country === parsed.country ? libphonenumber.format(parsed, 'National') :
|
|
10567
|
+
var parsed = libphonenumber.parse(raw, country);
|
|
10568
|
+
var phoneValue = country === parsed.country ? libphonenumber.format(parsed, 'National') : raw;
|
|
10205
10569
|
this.asYouType(phoneValue);
|
|
10206
10570
|
} catch (e) {}
|
|
10207
10571
|
}
|
|
@@ -10235,7 +10599,7 @@ var PhoneNumberField = /*#__PURE__*/function (_React$Component) {
|
|
|
10235
10599
|
id: inputId,
|
|
10236
10600
|
name: path,
|
|
10237
10601
|
type: "tel",
|
|
10238
|
-
value: value.
|
|
10602
|
+
value: value.raw || '',
|
|
10239
10603
|
placeholder: placeholder,
|
|
10240
10604
|
title: label,
|
|
10241
10605
|
required: required,
|
|
@@ -10264,12 +10628,12 @@ function phoneNumberField(props, config) {
|
|
|
10264
10628
|
bind: function bind(x) {
|
|
10265
10629
|
return {
|
|
10266
10630
|
country: config.countryCode,
|
|
10267
|
-
|
|
10631
|
+
raw: x,
|
|
10268
10632
|
isValid: true
|
|
10269
10633
|
};
|
|
10270
10634
|
},
|
|
10271
10635
|
unbind: function unbind(x) {
|
|
10272
|
-
return x.formatted || x.
|
|
10636
|
+
return x.formatted || x.raw;
|
|
10273
10637
|
}
|
|
10274
10638
|
},
|
|
10275
10639
|
validator: new Validator({
|
|
@@ -10765,11 +11129,13 @@ function consentField(config) {
|
|
|
10765
11129
|
unbind: function unbind(x) {
|
|
10766
11130
|
return {
|
|
10767
11131
|
granted: x,
|
|
10768
|
-
consentType: config.type
|
|
11132
|
+
consentType: config.type,
|
|
11133
|
+
consentVersion: config.extendedParams.version
|
|
10769
11134
|
};
|
|
10770
11135
|
}
|
|
10771
11136
|
},
|
|
10772
11137
|
validator: config.required ? checked : empty,
|
|
11138
|
+
rawProperty: 'granted',
|
|
10773
11139
|
component: ConsentField
|
|
10774
11140
|
}));
|
|
10775
11141
|
}
|
|
@@ -10935,15 +11301,31 @@ function customFieldComponent(customField, cfg) {
|
|
|
10935
11301
|
}
|
|
10936
11302
|
}
|
|
10937
11303
|
|
|
10938
|
-
function consentFieldComponent(consent, fieldConfig) {
|
|
11304
|
+
function consentFieldComponent(consent, fieldConfig, versionIdPath, language) {
|
|
10939
11305
|
if (fieldConfig.errorArchivedConsents && consent.status === 'archived') {
|
|
10940
11306
|
throw new UserError("The '".concat(consent.key, "' consent is archived and cannot be displayed."));
|
|
11307
|
+
} // If the version ID is not defined in the path, get the latest version ID
|
|
11308
|
+
|
|
11309
|
+
|
|
11310
|
+
var versionId = parseInt(versionIdPath || Math.max.apply(Math, _toConsumableArray(Object.values(consent.versions.map(function (v) {
|
|
11311
|
+
return v.versionId;
|
|
11312
|
+
})))));
|
|
11313
|
+
var version = consent.versions.find(function (version) {
|
|
11314
|
+
return version.versionId === versionId;
|
|
11315
|
+
});
|
|
11316
|
+
|
|
11317
|
+
if (!version) {
|
|
11318
|
+
throw new UserError("Unknown version ID n\xB0".concat(versionId, " of consent '").concat(consent.key, "'."));
|
|
10941
11319
|
}
|
|
10942
11320
|
|
|
10943
11321
|
var baseConfig = _objectSpread2(_objectSpread2({}, fieldConfig), {}, {
|
|
10944
|
-
label:
|
|
11322
|
+
label: version.title,
|
|
10945
11323
|
extendedParams: {
|
|
10946
|
-
|
|
11324
|
+
version: {
|
|
11325
|
+
versionId: versionId,
|
|
11326
|
+
language: language
|
|
11327
|
+
},
|
|
11328
|
+
description: version.description,
|
|
10947
11329
|
consentCannotBeGranted: !fieldConfig.errorArchivedConsents && consent.status === 'archived'
|
|
10948
11330
|
},
|
|
10949
11331
|
type: consent.consentType,
|
|
@@ -10961,7 +11343,7 @@ var findCustomField = function findCustomField(config, camelPath) {
|
|
|
10961
11343
|
};
|
|
10962
11344
|
|
|
10963
11345
|
var findConsentField = function findConsentField(config, camelPath) {
|
|
10964
|
-
return find(config.
|
|
11346
|
+
return find(config.consentsVersions, function (f) {
|
|
10965
11347
|
var fieldCamelPath = camelCase(f.key);
|
|
10966
11348
|
return camelPath === fieldCamelPath || camelPath === "consents.".concat(fieldCamelPath);
|
|
10967
11349
|
});
|
|
@@ -10980,10 +11362,11 @@ var resolveField = function resolveField(fieldConfig, config) {
|
|
|
10980
11362
|
return customFieldComponent(customField, fieldConfig);
|
|
10981
11363
|
}
|
|
10982
11364
|
|
|
10983
|
-
var
|
|
11365
|
+
var camelPathSplit = camelPath.split('.v');
|
|
11366
|
+
var consentField = findConsentField(config, camelPathSplit[0]);
|
|
10984
11367
|
|
|
10985
11368
|
if (consentField) {
|
|
10986
|
-
return consentFieldComponent(consentField, fieldConfig);
|
|
11369
|
+
return consentFieldComponent(consentField, fieldConfig, camelPathSplit[1], config.language);
|
|
10987
11370
|
}
|
|
10988
11371
|
|
|
10989
11372
|
throw new UserError("Unknown field: ".concat(fieldConfig.key));
|
|
@@ -11040,8 +11423,10 @@ var PasswordSignupForm = /*#__PURE__*/function (_React$Component) {
|
|
|
11040
11423
|
blacklist: []
|
|
11041
11424
|
});
|
|
11042
11425
|
|
|
11043
|
-
_defineProperty(_assertThisInitialized(_this), "
|
|
11426
|
+
_defineProperty(_assertThisInitialized(_this), "callback", function (data) {
|
|
11427
|
+
var captchaToken = extractCaptchaTokenFromData(data);
|
|
11044
11428
|
return _this.props.apiClient.signup({
|
|
11429
|
+
captchaToken: captchaToken,
|
|
11045
11430
|
data: snakeCaseProperties(data),
|
|
11046
11431
|
auth: _this.props.auth,
|
|
11047
11432
|
redirectUrl: _this.props && _this.props.redirectUrl,
|
|
@@ -11071,8 +11456,15 @@ var PasswordSignupForm = /*#__PURE__*/function (_React$Component) {
|
|
|
11071
11456
|
}
|
|
11072
11457
|
|
|
11073
11458
|
_createClass(PasswordSignupForm, [{
|
|
11459
|
+
key: "componentDidMount",
|
|
11460
|
+
value: function componentDidMount() {
|
|
11461
|
+
importGoogleRecaptchaScript(this.props.recaptcha_site_key);
|
|
11462
|
+
}
|
|
11463
|
+
}, {
|
|
11074
11464
|
key: "render",
|
|
11075
11465
|
value: function render() {
|
|
11466
|
+
var _this2 = this;
|
|
11467
|
+
|
|
11076
11468
|
var _this$props = this.props,
|
|
11077
11469
|
_this$props$beforeSig = _this$props.beforeSignup,
|
|
11078
11470
|
beforeSignup = _this$props$beforeSig === void 0 ? function (x) {
|
|
@@ -11103,7 +11495,9 @@ var PasswordSignupForm = /*#__PURE__*/function (_React$Component) {
|
|
|
11103
11495
|
beforeSubmit: beforeSignup,
|
|
11104
11496
|
onFieldChange: this.refreshBlacklist,
|
|
11105
11497
|
sharedProps: sharedProps,
|
|
11106
|
-
handler:
|
|
11498
|
+
handler: function handler(data) {
|
|
11499
|
+
return ReCaptcha.handle(data, _this2.props, _this2.callback, "signup");
|
|
11500
|
+
}
|
|
11107
11501
|
});
|
|
11108
11502
|
}
|
|
11109
11503
|
}]);
|
|
@@ -11261,10 +11655,29 @@ var skipError = function skipError(err) {
|
|
|
11261
11655
|
};
|
|
11262
11656
|
|
|
11263
11657
|
var enhance = recompose.withHandlers({
|
|
11264
|
-
|
|
11658
|
+
callback: function callback(_ref) {
|
|
11265
11659
|
var apiClient = _ref.apiClient,
|
|
11266
11660
|
redirectUrl = _ref.redirectUrl,
|
|
11267
|
-
returnToAfterPasswordReset = _ref.returnToAfterPasswordReset
|
|
11661
|
+
returnToAfterPasswordReset = _ref.returnToAfterPasswordReset,
|
|
11662
|
+
recaptcha_enabled = _ref.recaptcha_enabled,
|
|
11663
|
+
recaptcha_site_key = _ref.recaptcha_site_key;
|
|
11664
|
+
return function (data) {
|
|
11665
|
+
return ReCaptcha.handle(_objectSpread2(_objectSpread2({}, data), {}, {
|
|
11666
|
+
redirectUrl: redirectUrl,
|
|
11667
|
+
returnToAfterPasswordReset: returnToAfterPasswordReset
|
|
11668
|
+
}), {
|
|
11669
|
+
apiClient: apiClient,
|
|
11670
|
+
redirectUrl: redirectUrl,
|
|
11671
|
+
returnToAfterPasswordReset: returnToAfterPasswordReset,
|
|
11672
|
+
recaptcha_enabled: recaptcha_enabled,
|
|
11673
|
+
recaptcha_site_key: recaptcha_site_key
|
|
11674
|
+
}, apiClient.requestPasswordReset, "forgot_password");
|
|
11675
|
+
};
|
|
11676
|
+
},
|
|
11677
|
+
handleSubmit: function handleSubmit(_ref2) {
|
|
11678
|
+
var apiClient = _ref2.apiClient,
|
|
11679
|
+
redirectUrl = _ref2.redirectUrl,
|
|
11680
|
+
returnToAfterPasswordReset = _ref2.returnToAfterPasswordReset;
|
|
11268
11681
|
return function (data) {
|
|
11269
11682
|
return apiClient.requestPasswordReset(_objectSpread2(_objectSpread2({}, data), {}, {
|
|
11270
11683
|
redirectUrl: redirectUrl,
|
|
@@ -11273,17 +11686,18 @@ var enhance = recompose.withHandlers({
|
|
|
11273
11686
|
};
|
|
11274
11687
|
}
|
|
11275
11688
|
});
|
|
11276
|
-
var ForgotPasswordView = enhance(function (
|
|
11277
|
-
var i18n =
|
|
11278
|
-
goTo =
|
|
11279
|
-
allowLogin =
|
|
11280
|
-
|
|
11281
|
-
displaySafeErrorMessage =
|
|
11282
|
-
showLabels =
|
|
11283
|
-
allowWebAuthnLogin =
|
|
11284
|
-
|
|
11689
|
+
var ForgotPasswordView = enhance(function (_ref3) {
|
|
11690
|
+
var i18n = _ref3.i18n,
|
|
11691
|
+
goTo = _ref3.goTo,
|
|
11692
|
+
allowLogin = _ref3.allowLogin,
|
|
11693
|
+
callback = _ref3.callback,
|
|
11694
|
+
displaySafeErrorMessage = _ref3.displaySafeErrorMessage,
|
|
11695
|
+
showLabels = _ref3.showLabels,
|
|
11696
|
+
allowWebAuthnLogin = _ref3.allowWebAuthnLogin,
|
|
11697
|
+
recaptcha_site_key = _ref3.recaptcha_site_key;
|
|
11698
|
+
return /*#__PURE__*/React__default.createElement("div", null, importGoogleRecaptchaScript(recaptcha_site_key), /*#__PURE__*/React__default.createElement(Heading, null, i18n('forgotPassword.title')), /*#__PURE__*/React__default.createElement(Intro, null, i18n('forgotPassword.prompt')), /*#__PURE__*/React__default.createElement(ForgotPasswordForm, {
|
|
11285
11699
|
showLabels: showLabels,
|
|
11286
|
-
handler:
|
|
11700
|
+
handler: callback,
|
|
11287
11701
|
onSuccess: function onSuccess() {
|
|
11288
11702
|
return goTo('forgot-password-success');
|
|
11289
11703
|
},
|
|
@@ -11292,10 +11706,10 @@ var ForgotPasswordView = enhance(function (_ref2) {
|
|
|
11292
11706
|
target: allowWebAuthnLogin ? 'login-with-web-authn' : 'login'
|
|
11293
11707
|
}, i18n('forgotPassword.backToLoginLink'))));
|
|
11294
11708
|
});
|
|
11295
|
-
var ForgotPasswordSuccessView = function ForgotPasswordSuccessView(
|
|
11296
|
-
var i18n =
|
|
11297
|
-
allowLogin =
|
|
11298
|
-
allowWebAuthnLogin =
|
|
11709
|
+
var ForgotPasswordSuccessView = function ForgotPasswordSuccessView(_ref4) {
|
|
11710
|
+
var i18n = _ref4.i18n,
|
|
11711
|
+
allowLogin = _ref4.allowLogin,
|
|
11712
|
+
allowWebAuthnLogin = _ref4.allowWebAuthnLogin;
|
|
11299
11713
|
return /*#__PURE__*/React__default.createElement("div", null, /*#__PURE__*/React__default.createElement(Heading, null, i18n('forgotPassword.title')), /*#__PURE__*/React__default.createElement(Info, null, i18n('forgotPassword.successMessage')), allowLogin && /*#__PURE__*/React__default.createElement(Alternative, null, /*#__PURE__*/React__default.createElement(Link, {
|
|
11300
11714
|
target: allowWebAuthnLogin ? 'login-with-web-authn' : 'login'
|
|
11301
11715
|
}, i18n('back'))));
|
|
@@ -11869,6 +12283,105 @@ var phoneNumberEditorWidget = createMultiViewWidget({
|
|
|
11869
12283
|
}
|
|
11870
12284
|
});
|
|
11871
12285
|
|
|
12286
|
+
/**
|
|
12287
|
+
* The base implementation of `_.map` without support for iteratee shorthands.
|
|
12288
|
+
*
|
|
12289
|
+
* @private
|
|
12290
|
+
* @param {Array|Object} collection The collection to iterate over.
|
|
12291
|
+
* @param {Function} iteratee The function invoked per iteration.
|
|
12292
|
+
* @returns {Array} Returns the new mapped array.
|
|
12293
|
+
*/
|
|
12294
|
+
|
|
12295
|
+
function baseMap(collection, iteratee) {
|
|
12296
|
+
var index = -1,
|
|
12297
|
+
result = isArrayLike(collection) ? Array(collection.length) : [];
|
|
12298
|
+
baseEach(collection, function (value, key, collection) {
|
|
12299
|
+
result[++index] = iteratee(value, key, collection);
|
|
12300
|
+
});
|
|
12301
|
+
return result;
|
|
12302
|
+
}
|
|
12303
|
+
|
|
12304
|
+
/**
|
|
12305
|
+
* Creates an array of values by running each element in `collection` thru
|
|
12306
|
+
* `iteratee`. The iteratee is invoked with three arguments:
|
|
12307
|
+
* (value, index|key, collection).
|
|
12308
|
+
*
|
|
12309
|
+
* Many lodash methods are guarded to work as iteratees for methods like
|
|
12310
|
+
* `_.every`, `_.filter`, `_.map`, `_.mapValues`, `_.reject`, and `_.some`.
|
|
12311
|
+
*
|
|
12312
|
+
* The guarded methods are:
|
|
12313
|
+
* `ary`, `chunk`, `curry`, `curryRight`, `drop`, `dropRight`, `every`,
|
|
12314
|
+
* `fill`, `invert`, `parseInt`, `random`, `range`, `rangeRight`, `repeat`,
|
|
12315
|
+
* `sampleSize`, `slice`, `some`, `sortBy`, `split`, `take`, `takeRight`,
|
|
12316
|
+
* `template`, `trim`, `trimEnd`, `trimStart`, and `words`
|
|
12317
|
+
*
|
|
12318
|
+
* @static
|
|
12319
|
+
* @memberOf _
|
|
12320
|
+
* @since 0.1.0
|
|
12321
|
+
* @category Collection
|
|
12322
|
+
* @param {Array|Object} collection The collection to iterate over.
|
|
12323
|
+
* @param {Function} [iteratee=_.identity] The function invoked per iteration.
|
|
12324
|
+
* @returns {Array} Returns the new mapped array.
|
|
12325
|
+
* @example
|
|
12326
|
+
*
|
|
12327
|
+
* function square(n) {
|
|
12328
|
+
* return n * n;
|
|
12329
|
+
* }
|
|
12330
|
+
*
|
|
12331
|
+
* _.map([4, 8], square);
|
|
12332
|
+
* // => [16, 64]
|
|
12333
|
+
*
|
|
12334
|
+
* _.map({ 'a': 4, 'b': 8 }, square);
|
|
12335
|
+
* // => [16, 64] (iteration order is not guaranteed)
|
|
12336
|
+
*
|
|
12337
|
+
* var users = [
|
|
12338
|
+
* { 'user': 'barney' },
|
|
12339
|
+
* { 'user': 'fred' }
|
|
12340
|
+
* ];
|
|
12341
|
+
*
|
|
12342
|
+
* // The `_.property` iteratee shorthand.
|
|
12343
|
+
* _.map(users, 'user');
|
|
12344
|
+
* // => ['barney', 'fred']
|
|
12345
|
+
*/
|
|
12346
|
+
|
|
12347
|
+
function map(collection, iteratee) {
|
|
12348
|
+
var func = isArray(collection) ? arrayMap : baseMap;
|
|
12349
|
+
return func(collection, baseIteratee(iteratee));
|
|
12350
|
+
}
|
|
12351
|
+
|
|
12352
|
+
/**
|
|
12353
|
+
* Creates an object composed of the `object` properties `predicate` returns
|
|
12354
|
+
* truthy for. The predicate is invoked with two arguments: (value, key).
|
|
12355
|
+
*
|
|
12356
|
+
* @static
|
|
12357
|
+
* @memberOf _
|
|
12358
|
+
* @since 4.0.0
|
|
12359
|
+
* @category Object
|
|
12360
|
+
* @param {Object} object The source object.
|
|
12361
|
+
* @param {Function} [predicate=_.identity] The function invoked per property.
|
|
12362
|
+
* @returns {Object} Returns the new object.
|
|
12363
|
+
* @example
|
|
12364
|
+
*
|
|
12365
|
+
* var object = { 'a': 1, 'b': '2', 'c': 3 };
|
|
12366
|
+
*
|
|
12367
|
+
* _.pickBy(object, _.isNumber);
|
|
12368
|
+
* // => { 'a': 1, 'c': 3 }
|
|
12369
|
+
*/
|
|
12370
|
+
|
|
12371
|
+
function pickBy(object, predicate) {
|
|
12372
|
+
if (object == null) {
|
|
12373
|
+
return {};
|
|
12374
|
+
}
|
|
12375
|
+
|
|
12376
|
+
var props = arrayMap(getAllKeysIn(object), function (prop) {
|
|
12377
|
+
return [prop];
|
|
12378
|
+
});
|
|
12379
|
+
predicate = baseIteratee(predicate);
|
|
12380
|
+
return basePickBy(object, props, function (value, path) {
|
|
12381
|
+
return predicate(value, path[0]);
|
|
12382
|
+
});
|
|
12383
|
+
}
|
|
12384
|
+
|
|
11872
12385
|
function parseQueryString(value) {
|
|
11873
12386
|
var qs = value.split('&').reduce(function (acc, param) {
|
|
11874
12387
|
var _param$split = param.split('='),
|
|
@@ -11881,6 +12394,15 @@ function parseQueryString(value) {
|
|
|
11881
12394
|
}, {});
|
|
11882
12395
|
return camelCaseProperties(qs);
|
|
11883
12396
|
}
|
|
12397
|
+
function toQueryString(obj) {
|
|
12398
|
+
var snakeCase = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
|
|
12399
|
+
var params = snakeCase ? snakeCaseProperties(obj) : obj;
|
|
12400
|
+
return map(pickBy(params, function (v) {
|
|
12401
|
+
return v !== null && v !== undefined;
|
|
12402
|
+
}), function (value, key) {
|
|
12403
|
+
return value !== '' ? "".concat(key, "=").concat(encodeURIComponent(value)) : key;
|
|
12404
|
+
}).join('&');
|
|
12405
|
+
}
|
|
11884
12406
|
|
|
11885
12407
|
var MainView$2 = /*#__PURE__*/function (_React$Component) {
|
|
11886
12408
|
_inherits(MainView, _React$Component);
|
|
@@ -12003,7 +12525,7 @@ var MainView$3 = /*#__PURE__*/function (_React$Component) {
|
|
|
12003
12525
|
|
|
12004
12526
|
_this = _super.call.apply(_super, [this].concat(args));
|
|
12005
12527
|
|
|
12006
|
-
_defineProperty(_assertThisInitialized(_this), "
|
|
12528
|
+
_defineProperty(_assertThisInitialized(_this), "callback", function (data) {
|
|
12007
12529
|
return _this.props.apiClient.startPasswordless(data, _this.props.auth).then(function (_) {
|
|
12008
12530
|
return data;
|
|
12009
12531
|
});
|
|
@@ -12017,8 +12539,15 @@ var MainView$3 = /*#__PURE__*/function (_React$Component) {
|
|
|
12017
12539
|
}
|
|
12018
12540
|
|
|
12019
12541
|
_createClass(MainView, [{
|
|
12542
|
+
key: "componentDidMount",
|
|
12543
|
+
value: function componentDidMount() {
|
|
12544
|
+
importGoogleRecaptchaScript(this.props.recaptcha_site_key);
|
|
12545
|
+
}
|
|
12546
|
+
}, {
|
|
12020
12547
|
key: "render",
|
|
12021
12548
|
value: function render() {
|
|
12549
|
+
var _this2 = this;
|
|
12550
|
+
|
|
12022
12551
|
var _this$props = this.props,
|
|
12023
12552
|
i18n = _this$props.i18n,
|
|
12024
12553
|
showSocialLogins = _this$props.showSocialLogins,
|
|
@@ -12033,10 +12562,14 @@ var MainView$3 = /*#__PURE__*/function (_React$Component) {
|
|
|
12033
12562
|
}), showSocialLogins && socialProviders && socialProviders.length > 0 && /*#__PURE__*/React__default.createElement(Separator, {
|
|
12034
12563
|
text: i18n('or')
|
|
12035
12564
|
}), isEmail && showIntro && /*#__PURE__*/React__default.createElement(Intro, null, i18n('passwordless.intro')), isEmail && /*#__PURE__*/React__default.createElement(EmailInputForm, {
|
|
12036
|
-
handler:
|
|
12565
|
+
handler: function handler(data) {
|
|
12566
|
+
return ReCaptcha.handle(data, _this2.props, _this2.callback, "passwordless_email");
|
|
12567
|
+
},
|
|
12037
12568
|
onSuccess: this.handleSuccess
|
|
12038
12569
|
}), !isEmail && showIntro && /*#__PURE__*/React__default.createElement(Intro, null, i18n('passwordless.sms.intro')), !isEmail && /*#__PURE__*/React__default.createElement(PhoneNumberInputForm, {
|
|
12039
|
-
handler:
|
|
12570
|
+
handler: function handler(data) {
|
|
12571
|
+
return ReCaptcha.handle(data, _this2.props, _this2.callback, "passwordless_phone");
|
|
12572
|
+
},
|
|
12040
12573
|
onSuccess: this.handleSuccess
|
|
12041
12574
|
}));
|
|
12042
12575
|
}
|
|
@@ -12051,7 +12584,7 @@ var VerificationCodeView$1 = /*#__PURE__*/function (_React$Component2) {
|
|
|
12051
12584
|
var _super2 = _createSuper(VerificationCodeView);
|
|
12052
12585
|
|
|
12053
12586
|
function VerificationCodeView() {
|
|
12054
|
-
var
|
|
12587
|
+
var _this3;
|
|
12055
12588
|
|
|
12056
12589
|
_classCallCheck(this, VerificationCodeView);
|
|
12057
12590
|
|
|
@@ -12059,26 +12592,30 @@ var VerificationCodeView$1 = /*#__PURE__*/function (_React$Component2) {
|
|
|
12059
12592
|
args[_key2] = arguments[_key2];
|
|
12060
12593
|
}
|
|
12061
12594
|
|
|
12062
|
-
|
|
12595
|
+
_this3 = _super2.call.apply(_super2, [this].concat(args));
|
|
12063
12596
|
|
|
12064
|
-
_defineProperty(_assertThisInitialized(
|
|
12065
|
-
var
|
|
12066
|
-
apiClient =
|
|
12067
|
-
auth =
|
|
12068
|
-
phoneNumber =
|
|
12597
|
+
_defineProperty(_assertThisInitialized(_this3), "handleSubmit", function (data) {
|
|
12598
|
+
var _this3$props = _this3.props,
|
|
12599
|
+
apiClient = _this3$props.apiClient,
|
|
12600
|
+
auth = _this3$props.auth,
|
|
12601
|
+
phoneNumber = _this3$props.phoneNumber;
|
|
12069
12602
|
return apiClient.verifyPasswordless(_objectSpread2({
|
|
12070
12603
|
phoneNumber: phoneNumber
|
|
12071
12604
|
}, data), auth);
|
|
12072
12605
|
});
|
|
12073
12606
|
|
|
12074
|
-
return
|
|
12607
|
+
return _this3;
|
|
12075
12608
|
}
|
|
12076
12609
|
|
|
12077
12610
|
_createClass(VerificationCodeView, [{
|
|
12078
12611
|
key: "render",
|
|
12079
12612
|
value: function render() {
|
|
12613
|
+
var _this4 = this;
|
|
12614
|
+
|
|
12080
12615
|
return /*#__PURE__*/React__default.createElement("div", null, /*#__PURE__*/React__default.createElement(Info, null, this.props.i18n('passwordless.sms.verification.intro')), /*#__PURE__*/React__default.createElement(VerificationCodeInputForm$1, {
|
|
12081
|
-
handler:
|
|
12616
|
+
handler: function handler(data) {
|
|
12617
|
+
return ReCaptcha.handle(data, _this4.props, _this4.callback, "verify_passwordless_sms");
|
|
12618
|
+
}
|
|
12082
12619
|
}));
|
|
12083
12620
|
}
|
|
12084
12621
|
}]);
|
|
@@ -15120,10 +15657,18 @@ function createClient(creationConfig) {
|
|
|
15120
15657
|
var client = coreClient.remoteSettings.then(function (remoteSettings) {
|
|
15121
15658
|
var remoteConfig = camelCaseProperties(remoteSettings);
|
|
15122
15659
|
var language = creationConfig.language || remoteConfig.language;
|
|
15123
|
-
return fetch("".concat(
|
|
15660
|
+
return fetch("https://".concat(creationConfig.domain, "/identity/v1/config/consents?").concat(toQueryString({
|
|
15661
|
+
lang: language
|
|
15662
|
+
}))).then(function (response) {
|
|
15124
15663
|
return response.json();
|
|
15125
|
-
}).then(function (
|
|
15126
|
-
return
|
|
15664
|
+
}).then(function (consentsVersions) {
|
|
15665
|
+
return fetch("".concat(remoteSettings.resourceBaseUrl, "/").concat(language, ".json")).then(function (response) {
|
|
15666
|
+
return response.json();
|
|
15667
|
+
}).then(function (defaultI18n) {
|
|
15668
|
+
return new UiClient(_objectSpread2(_objectSpread2(_objectSpread2({}, creationConfig), remoteConfig), {}, {
|
|
15669
|
+
consentsVersions: camelCaseProperties(consentsVersions)
|
|
15670
|
+
}), urlParser, coreClient, defaultI18n);
|
|
15671
|
+
})["catch"](console.error);
|
|
15127
15672
|
})["catch"](console.error);
|
|
15128
15673
|
});
|
|
15129
15674
|
return {
|