# Unable to Login with the user name for the login page instead of user Email

**URL:** <https://community.auth0.com/t/unable-to-login-with-the-user-name-for-the-login-page-instead-of-user-email/148389>\
**Category:** Get Help\
**Tags:** user-profile, user-management\
**Created:** [October 2, 2024, 11:54am UTC](https://community.auth0.com/t/unable-to-login-with-the-user-name-for-the-login-page-instead-of-user-email/148389 "2024-10-02T11:54:23Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![yellowblockllp](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/yellowblockllp/32/50901_2.png) [@yellowblockllp](https://community.auth0.com/u/yellowblockllp)\
**Post date:** [October 2, 2024, 11:54am UTC](https://community.auth0.com/t/unable-to-login-with-the-user-name-for-the-login-page-instead-of-user-email/148389/1 "2024-10-02T11:54:23Z")

</div>

in one of our tenant we are using custom database in Authentication for our application in that for login page we have written the code for the to login using email or username. when the user uses the email for the login its working fine but when the same user try to go through his user name its showing that invalid email,user,password.

we are using the below query. we are using tedious library in my code

console.log(email,“Email”);  
const query = ‘SELECT Id, UserName, Email, PasswordHash FROM dbo.AspNetUsers WHERE Email = @Email or UserName = @Email’;  
const query1 = ‘SELECT ClaimType, ClaimValue FROM dbo.AspNetUserClaims WHERE UserId = @UserId and (ClaimType=@Idr or ClaimType=@Idc or ClaimType=@Ecode)’;

we have tried to add the user parameter in the login code and console logs for errors  
when we have checked the logs the data for the user is there but the user is still unable to access the application through the username

does any one know why its not working

 ![image](https://global.discourse-cdn.com/auth0/original/3X/1/b/1b8e92afc51227040b7c85a1c0c5e4d123a4467a.png)

---

<div class="post-metadata">

**Author:** ![rueben.tiow](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/rueben.tiow/32/11646_2.png) [@rueben.tiow](https://community.auth0.com/u/rueben.tiow)\
**Post date:** [October 9, 2024, 4:38pm UTC](https://community.auth0.com/t/unable-to-login-with-the-user-name-for-the-login-page-instead-of-user-email/148389/3 "2024-10-09T16:38:15Z")

</div>

Hi @yellowblockllp,

I suggest checking your tenant logs to see what is the source of the issue for the failed login.

It might also be worth using the [Real-time Webtask Logs Extension](https://auth0.com/docs/customize/extensions/real-time-webtask-logs) to debug your custom database action scripts. You should be able to find clues as to why the login failed with the username and not with email.

Let me know how this goes for you.

Thanks,  
Rueben

---

<div class="post-metadata">

**Author:** ![yellowblockllp](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/yellowblockllp/32/50901_2.png) [@yellowblockllp](https://community.auth0.com/u/yellowblockllp)\
**Post date:** [October 11, 2024, 4:03pm UTC](https://community.auth0.com/t/unable-to-login-with-the-user-name-for-the-login-page-instead-of-user-email/148389/4 "2024-10-11T16:03:23Z")

</div>

Hi @rueben.tiow

I verified, No issue on scripts it’s everything fine. but ii gor issue Like " returned profile does not contain specified identifying attribute".

 ![image](https://global.discourse-cdn.com/auth0/original/3X/b/4/b4a564ed1753f6cf1ec25128c80964f5dbb0e6a6.png)

 ![image](https://global.discourse-cdn.com/auth0/original/3X/d/5/d5df337b3ff770f887d8d5595193edd775bed21f.jpeg)

 ![image](https://global.discourse-cdn.com/auth0/original/3X/f/f/ff03512223fdf8235d7571c545733f0fcaf1e91f.png)

---

<div class="post-metadata">

**Author:** ![yellowblockllp](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/yellowblockllp/32/50901_2.png) [@yellowblockllp](https://community.auth0.com/u/yellowblockllp)\
**Post date:** [October 15, 2024, 7:19am UTC](https://community.auth0.com/t/unable-to-login-with-the-user-name-for-the-login-page-instead-of-user-email/148389/5 "2024-10-15T07:19:48Z")

</div>

Hi, @rueben.tiow  
Based on the above information, at script no issue was found. i am getting the issue “returned profile does not contain specified identifying attribute” when i verify login and try on the custom DB function.

---

<div class="post-metadata">

**Author:** ![yellowblockllp](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/yellowblockllp/32/50901_2.png) [@yellowblockllp](https://community.auth0.com/u/yellowblockllp)\
**Post date:** [October 17, 2024, 3:55am UTC](https://community.auth0.com/t/unable-to-login-with-the-user-name-for-the-login-page-instead-of-user-email/148389/6 "2024-10-17T03:55:02Z")

</div>

Hi, @rueben.tiow  
Based on the above information, at script no issue was found. i am getting the issue “returned profile does not contain specified identifying attribute” when i verify login and try on the custom DB function.

any update on my issue.

---

<div class="post-metadata">

**Author:** ![rueben.tiow](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/rueben.tiow/32/11646_2.png) [@rueben.tiow](https://community.auth0.com/u/rueben.tiow)\
**Post date:** [October 24, 2024, 8:10pm UTC](https://community.auth0.com/t/unable-to-login-with-the-user-name-for-the-login-page-instead-of-user-email/148389/7 "2024-10-24T20:10:45Z")

</div>

Hi @yellowblockllp,

Thanks for your responses.

You might need to review the user profile in the callback URL to include the `idr`, `idc`, and `ecode` properties in the user\_metadata or app\_metadata if they represent non-identifying attributes.

For example:

```auto
callback(null, {
  user_id: user.profile.user_id,
  email: user.profile.email,
  nickname: user.profile.nickname,

  user_metadata: {
    idr: idr,
    idc: idc,
    ecode: ecode
  }
});

```

Let me know how this goes for you.

Thanks,  
Rueben

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/auth0/original/3X/b/5/b560f266932fcce5d57f09a6595bd50518cae3f3.jpeg) [@system](https://community.auth0.com/u/system)\
**Post date:** [November 7, 2024, 8:10pm UTC](https://community.auth0.com/t/unable-to-login-with-the-user-name-for-the-login-page-instead-of-user-email/148389/8 "2024-11-07T20:10:58Z")

</div>

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.
