Add case-sensitive email option for User model - #1804
Conversation
There was a problem hiding this comment.
if (this.settings.caseSensitiveEmail)
There was a problem hiding this comment.
Actually, can't you just set this default to true somewhere before? ie. When configs are read in, etc.
There was a problem hiding this comment.
I couldn't change the setting in a boot script if I set it to true in user.js. Maybe I'm just trying to set it in the wrong place? Do you have a line number you could refer me to?
|
Added comments. Also, can you write a test that fails and then make it pass? |
|
@superkhau, I actually had some issues with |
|
I am not very comfortable with modifying the email values to achieve case-insensitive comparison. It may lead to confusing situations, e.g. await User.create({ email: 'mbajtos@cz.ibm.com', password: 'pass' });
var list = await User.find({ where: { email: 'mbajtos@cz.ibm.com' });
// no user foundIMO, we should use case-insensitive query operator instead. IIRC it was you @superkhau who implemented it? |
As long as this is clear in the documentation, I think its fine.
.... said no one ever. |
Yeah, we have the regex operator, which can take a a |
Not sure who the repo expert is for this particular repo. @ritch? |
There was a problem hiding this comment.
@superkhau @bajtos, can you guys review my changes to this test file?
Most people don't read documentation. I personally wouldn't even know where (in which part of the documentation) to look for this information.
I think this is subjective, but let's say you are right and people won't mind LoopBack sanitising the email address on input. In that case I would like LoopBack to also sanitise email addresses in all queries, so that my example keeps working: await User.create({ email: 'MBajtos@cz.ibm.com', password: 'pass' });
// email is stored as "mbajtos@cz.ibm.com"
var list = await User.find({ where: { email: 'MBajtos@cz.ibm.com' });
// the query is modified to email: "mbajtos@cz.ibm.com" |
There was a problem hiding this comment.
Please use this form: if (err) return done(err). It produces stack traces pointing to the original error, as opposed to assert(!err) which points to this line in tests. Please apply this rule to all new tests you are adding in this patch (no need to change existing code).
There was a problem hiding this comment.
I followed the same conventions at the other tests in that describe block. Should I replace assert(!err) in all cases then?
There was a problem hiding this comment.
I followed the same conventions at the other tests in that describe block.
It's an old convention that I would like us to eventually get rid of.
Should I replace assert(!err) in all cases then?
I don't mind either. However, if you decide to fix existing tests, then make it in a standalone commit. This will make future inspection (code archaeology) much easier.
You are on the right track 👍 , I left few comments on what should be improved. |
There was a problem hiding this comment.
This case is confusing. You're trying to log in with validCaseInsenstiveEmailCredentials and expect an error?
There was a problem hiding this comment.
Good catch, @superkhau. I think the name validCaseInsensitiveEmailCredentials is confusing. The variable contains credentials that are invalid by default but valid when case-insensitive check is made.
|
@slnode test please |
|
@richardpringle could you please add an |
|
test please |
|
@slnode test please |
I'm not quite sure what you mean. Make another remote method? |
|
@slnode test please |
Sorry for the confusion. Just check that when you disable |
3bf6970 to
b10f224
Compare
There was a problem hiding this comment.
@bajtos, does this look good? Wasn't too sure about case description...
|
@elkorep, Could you please take a look at the failed checks here? Everything passes on my machine... |
|
@richardpringle LGTM 👍 , please squash the commits to a single one. |
232336d to
2cca83c
Compare
|
@richardpringle I am using this as one of my investigations. Look here for some reports on failed checks https://github.com/strongloop-internal/scrum-loopback/issues/630 |
|
Thanks @elkorep, looks like most (if not all) of the issues are concerning the npm registry or the modules within. Is that accurate? |
|
@richardpringle it seems like the failures are caused by npm and the ones with Error status are being aborted for some reason from what I have investigated so far. |
|
@slnode test please |
1 similar comment
|
@slnode test please |
|
I am going to ignore failing downstream builds and land this now. |
Add case-sensitive email option for User model
|
@richardpringle could you please work with @crandmck to get this new feature described in the documentation (docs or apidocs or both)? |
Have not created a test file for this yet. @ritch could you review this please (if you get a chance)?
Fix #1150
Connect to #1150