mirror of
https://github.com/Unleash/unleash.git
synced 2025-09-28 17:55:15 +02:00
fix: after encryption some emails end up being too long (#7828)
Encountered this case after encrypting an already long email address. This should mitigate the issue in demo instance. I don't think it's a big issue to ignore the length when validating an email address cause this is already limited at the DB layer by the column length
This commit is contained in:
parent
6af23ecbdc
commit
f9d077209f
@ -220,7 +220,11 @@ class UserService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (email) {
|
if (email) {
|
||||||
Joi.assert(email, Joi.string().email(), 'Email');
|
Joi.assert(
|
||||||
|
email,
|
||||||
|
Joi.string().email({ ignoreLength: true }),
|
||||||
|
'Email',
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
const exists = await this.store.hasUser({ username, email });
|
const exists = await this.store.hasUser({ username, email });
|
||||||
@ -264,7 +268,11 @@ class UserService {
|
|||||||
const preUser = await this.getUser(id);
|
const preUser = await this.getUser(id);
|
||||||
|
|
||||||
if (email) {
|
if (email) {
|
||||||
Joi.assert(email, Joi.string().email(), 'Email');
|
Joi.assert(
|
||||||
|
email,
|
||||||
|
Joi.string().email({ ignoreLength: true }),
|
||||||
|
'Email',
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (rootRole) {
|
if (rootRole) {
|
||||||
|
@ -39,8 +39,17 @@ test('Should create user with only email defined', () => {
|
|||||||
|
|
||||||
test('Should require valid email', () => {
|
test('Should require valid email', () => {
|
||||||
expect(() => {
|
expect(() => {
|
||||||
new User({ id: 11, email: 'some@' }); // eslint-disable-line
|
new User({ id: 11, email: 'some@' });
|
||||||
}).toThrowError(Error('Email "value" must be a valid email'));
|
}).toThrow(Error('Email "value" must be a valid email'));
|
||||||
|
});
|
||||||
|
|
||||||
|
test('Should allow long emails on demo', () => {
|
||||||
|
expect(() => {
|
||||||
|
new User({
|
||||||
|
id: 11,
|
||||||
|
email: '0a1c1b6a59a582fdbe853739eefc599dxd1eb365eee385e345b5fc41f59172022a8f69c09f61121d8b4a155b792314ee@unleash.run',
|
||||||
|
});
|
||||||
|
}).not.toThrow();
|
||||||
});
|
});
|
||||||
|
|
||||||
test('Should create user with only username defined', () => {
|
test('Should create user with only username defined', () => {
|
||||||
|
@ -83,7 +83,7 @@ export default class User implements IUser {
|
|||||||
if (!id) {
|
if (!id) {
|
||||||
throw new ValidationError('Id is required', [], undefined);
|
throw new ValidationError('Id is required', [], undefined);
|
||||||
}
|
}
|
||||||
Joi.assert(email, Joi.string().email(), 'Email');
|
Joi.assert(email, Joi.string().email({ ignoreLength: true }), 'Email');
|
||||||
Joi.assert(username, Joi.string(), 'Username');
|
Joi.assert(username, Joi.string(), 'Username');
|
||||||
Joi.assert(name, Joi.string(), 'Name');
|
Joi.assert(name, Joi.string(), 'Name');
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user