`login` fails when `identifierKey` leads to a falsy value
shaheer-2000 opened this issue · 4 comments
Package version
8.2.3
Describe the bug
When identifierKey
leads to a falsy value (say user[identifierKey] === 0), login
(as a result of getUserForLogin
failing) fails with the exception Cannot login user. Value of "${identifierKey}" is not defined
.
Is this intended? If not, ideally the check should be for undefined
and null
values.
Lines 128 to 129 in 71c09d1
Reproduction repo
No response
Why the id will be falsy?
@thetutlage although identifierKey should ideally be the primaryKey, it isn't guaranteed that this would be a non-zero value. I agree that ideally it should be auto-incrementing, 1-based
If it is expected to always be 1-based, non-zero value, then there should be a clear mention of it in documentation or the error thrown imo (hence why I asked if this was intentional)
Not sure why such an obvious thing should be mentioned clearly in the docs.
You are authenticating a user and your system cannot guarantee that user will have an id, then you should look into fixing that
The user does have an id (integer) and that's 0, as per my previous comment. It isn't the system that's at fault here, but I see you've marked this as completed, so I'll assume this is intentional and id should always be 1-based.
Thanks for your time, and apologies for the non-issue.