How can I make it so my html/js login/forgotPassword input-fields accept identity OR email fer login id?
Hi @JesterOC
The server will match only value from the âidentityâ column, so for instance:
- you have âusernameâ and âemailâ columns in your Users table
- the âusernameâ is the identity column
- the login/forgotPassword api expects the âusernameâ only
You want to allow your customers to use both âemailâ or âusernameâ, is that correct?
Well, to achieve this, you can use before EventHandlers to run your custom logic before the system operation:
- find a user with
property1 == {loginInput} or property2 == {loginInput} or propertyX == {loginInput} - then use the identity column value to login
Same for other operations
Regards,
Vlad
Trying it now, but only displayName (my identity column) is logging in..
email says invalid login or password.
error message from console says
POST https://api.backendless.com/FF55A111-06AF-7EB1-FFDE-B5B62760CA00/C1E76A66-370C-4491-B48E-57AC3520FCA7/users/login
401 (Unauthorized)
could you please provide curl of the login request to see what your request payload look like.
You can use fake credentials for now
idk exactly what curl is or how to use it so youâd have to walk me through it..
my js code im using looks like this
Backendless.UserService.login(login.username, login.password).then(
function (user) {
user ? showLoginSuccess(user) : showInfo("Login failed");
},
onError
);
try to add a print and check if it can load/find a user with the query
i added logging to print user value
logs say
2025-10-27 14:21:10,324 | SERVER_CODE | INFO | [3961564] [fb677189-833f-42f5-b054-a88f623c4e0c] [INVOKE HANDLER] user.beforeLogin (async)
2025-10-27 14:21:10,513 | TEST | ERROR | [{â___classâ:âUsersâ,âSERIALâ:â354B4784CD6AC92EBBC2â,âlastLoginâ:1761574486000,âcharacter_dataâ:{âIâm the bossâ:â1337â},âuserStatus":âENABLEDâ,âgenderâ:1,âcreatedâ:1615400957000,âdisplayNameâ:âJesterOCâ,âaccountTypeâ:âBACKENDLESSâ,âinit_user_upon_loginâ:false,âskinâ:11,âPAIDâ:true,âavatarâ:null,âsocialAccountâ:âBACKENDLESSâ,âownerIdâ:âB7A24F67-7D8C-4E91-9647-057871EB48E0â,âoAuthIdentitiesâ:null,âhasTesterRoleâ:false,âblUserLocaleâ:âenâ,âupdatedâ:1757774583103,âobjectIdâ:âB7A24F67-7D8C-4E91-9647-057871EB48E0â,âemailâ:"ocey92@gmail.comâ}]
2025-10-27 14:21:10,514 | SERVER_CODE | ERROR | [3961564] Error: the first argument must be either a string or a number
at Users._callee2$ (/usr/local/lib/node_modules/backendless-coderunner/node_modules/backendless/lib/users/index.js:79:21)
at Users. (/usr/local/lib/node_modules/backendless-coderunner/node_modules/@babel/runtime/helpers/regeneratorRuntime.js:52:18)
at Generator. (/usr/local/lib/node_modules/backendless-coderunner/node_modules/@babel/runtime/helpers/regenerator.js:52:51)
at Generator.next (/usr/local/lib/node_modules/backendless-coderunner/node_modules/@babel/runtime/helpers/regeneratorDefine.js:11:21)
at asyncGeneratorStep (/usr/local/lib/node_modules/backendless-coderunner/node_modules/@babel/runtime/helpers/asyncToGenerator.js:3:17)
at _next (/usr/local/lib/node_modules/backendless-coderunner/node_modules/@babel/runtime/helpers/asyncToGenerator.js:17:9)
at /usr/local/lib/node_modules/backendless-coderunner/node_modules/@babel/runtime/helpers/asyncToGenerator.js:22:7
at new Promise ()
at Users. (/usr/local/lib/node_modules/backendless-coderunner/node_modules/@babel/runtime/helpers/asyncToGenerator.js:14:12)
at Users.login (/usr/local/lib/node_modules/backendless-coderunner/node_modules/backendless/lib/users/index.js:122:24)
update.
the get_property âdisplayNameâ of user variable is the issue. it returns undefined
i tried checking if get property âemailâ printed, it was also undefined..
I donât see why it would be undefined⌠both of those properties exist in user variable
I see, the Find Records block returns a list of objects, need to retrieve the first element from the list
Iâm not familiar with getting the property out of the list, can you detail how to get the first element? and the displayName parameter?
update:
I can get the displayName now, however..
âInvalid login or passwordâ is the result if i try login with email
POST 401 (Unauthorized)
logging in with displayName still works.. got me buggered. I wouldâve thought it should be solved now that I can pass the identity to login codeblock.
iâll try it but i had a slightly different implementation where I got the object in the list and then "get property âdisplayNameâ worked.. but as i said it was still given me an error
iâll try your implementation and see if it makes a differ
Still an error with email somehow⌠it finds the user from the table and i can print the displayName (identity column).
No idea why it says 401 (Unauthorized) for the users/login POST though
heres the full error from the console.. logs report no errors but it fails with an error if i try email
https://api.backendless.com/FF55A111-06AF-7EB1-FFDE-B5B62760CA00/C1E76A66-370C-4491-B48E-57AC3520FCA7/users/login 401 (Unauthorized)
||sendRequest|@|backendless.js:13430|
||sendXmlHttpRequest|@|backendless.js:13391|
||(anonymous)|@|backendless.js:13049|
||send|@|backendless.js:12961|
||then|@|backendless.js:12982|
||_callee2$|@|backendless.js:11014|
||tryCatch|@|backendless.js:24202|
||(anonymous)|@|backendless.js:24290|
||(anonymous)|@|backendless.js:24231|
||asyncGeneratorStep|@|backendless.js:23791|
||_next|@|backendless.js:23805|
||(anonymous)|@|backendless.js:23810|
||webpack_modules../node_modules/@babel/runtime/helpers/asyncToGenerator.js.module.exports|@|backendless.js:23802|
||login|@|backendless.js:11024|
||loginUser|@|user-login.js:141|
||dispatch|@|jquery.min.js:2|
||(anonymous)|
any idea why itâs failing?
this sort of implementation works if i deactivate non-blocking option in event handlers.
Thanks for all your help Vladimir ![]()
Itâs now working as expected




