# Auth0 database store VS custom database

**URL:** <https://community.auth0.com/t/auth0-database-store-vs-custom-database/6261>\
**Category:** Get Help\
**Tags:** social, database-store, database, login, auth0\
**Created:** [April 18, 2017, 9:56pm UTC](https://community.auth0.com/t/auth0-database-store-vs-custom-database/6261 "2017-04-18T21:56:52Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![sandy](https://upload.wikimedia.org/wikipedia/commons/thumb/7/7c/User_font_awesome.svg/768px-User_font_awesome.svg.png) [@sandy](https://community.auth0.com/u/sandy)\
**Post date:** [April 18, 2017, 9:56pm UTC](https://community.auth0.com/t/auth0-database-store-vs-custom-database/6261/1 "2017-04-18T21:56:52Z")

</div>

Hi,

I’m having trouble determining what is the best solution for me.

The reason I started looking into Auth0 is I wanted a way to store my user data without having to worry about writing all the scripts for encrypting the user data such as passwords. I wanted to use Auth0’s database store.. but I’m beginning to think that it can’t provide me the user data that I need to store.

In the database, I need my users to have a username field, password field, and a second password. This second password you can think of as an access code (It can be the same for all users). This password will be sent to another API that will need it in order to handle sending messages for users.

My initial thought is that I could set a global password where I can call the API from the post-registration web hook to insert this password into their database… but then, I’m not sure how I can retreive this password from my mobile side code? My other issue is that each user MUST have a unique username that they cannot change. This username will be inserted into the API’s database.

My other issue is that I noticed Social Logins do not create a username field. =( A username field would be required because I need a field that will ALWAYS stay the same so that I could grab that data from Auth0’s database and send it to the other API’s database. And then when I need the information I still need to know what username was stored in the other API’s database for the user.

Anyone have any suggestions?

If I went with a custom database on Auth0, what are the disadvantages?? Would this still prevent me from offering social login… because I still need a unique username?? Is there a way to auto-generate a username field for ALL login types? Would I still have to figure out encryption if I used a custom database???

---

<div class="post-metadata">

**Author:** ![prashantT](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/prashantt/32/6002_2.png) [@prashantT](https://community.auth0.com/u/prashantT)\
**Post date:** [April 19, 2017, 12:54pm UTC](https://community.auth0.com/t/auth0-database-store-vs-custom-database/6261/2 "2017-04-19T12:54:12Z")

</div>

> In the database, I need my users to  
> have a username field, password field,  
> and a second password. This second  
> password you can think of as an access  
> code (It can be the same for all  
> users). This password will be sent to  
> another API that will need it in order  
> to handle sending messages for users.

Auth0 Database connections support usernames - this can be easily toggled from the Auth0 dashboard:

> **[Adding Username for Database Connections](https://auth0.com/docs/authenticate/database-connections/require-username)**
>
> Learn how to add a username field for login to database connections.

Your `second password` requirement can be handled by `app_metadata`. App\_metadata is stored under the user profile, however cannot be modified by the user. As you mentioned, you can add `app_metadata` to a user using the [Post User Registration hook](https://auth0.com/docs/hooks). You can then retrieve this in your application with a call to the [/userinfo](https://auth0.com/docs/api/authentication#get-user-info) or /tokeninfo endpoints.

**Note: If you are using your `second password` as a way to securing your API calls, you should take a look at our [API Authorization](https://auth0.com/docs/api-auth) docs to see how you can handle this more securely.**

> A username field would be required  
> because I need a field that will  
> ALWAYS stay the same so that I could  
> grab that data from Auth0’s database  
> and send it to the other API’s  
> database. And then when I need the  
> information I still need to know what  
> username was stored in the other API’s  
> database for the user.

As mentioned above, you can store a custom `username` field in `app_metadata`. **As a side note, it would be easier and more efficient (less API calls to Auth0 to retrieve userinfo) to use the `user_id` as the identifier in your database, rather than username.**

---

<div class="post-metadata">

**Author:** ![sandy](https://upload.wikimedia.org/wikipedia/commons/thumb/7/7c/User_font_awesome.svg/768px-User_font_awesome.svg.png) [@sandy](https://community.auth0.com/u/sandy)\
**Post date:** [April 19, 2017, 8:56pm UTC](https://community.auth0.com/t/auth0-database-store-vs-custom-database/6261/3 "2017-04-19T20:56:39Z")

</div>

I thought that if I added a password field to the metadata then the password is no longer secure… encrypted?

Do you know if social logins also have the user\_id field?? If I have this set to merge accounts (for same email address), which user\_id would it keep??

I’m also running into a 500 error when I try to call my REST service from a web hook. I need this REST to be called every time a user registers an account. Any ideas?

---

<div class="post-metadata">

**Author:** ![prashantT](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/prashantt/32/6002_2.png) [@prashantT](https://community.auth0.com/u/prashantT)\
**Post date:** [April 20, 2017, 12:42pm UTC](https://community.auth0.com/t/auth0-database-store-vs-custom-database/6261/4 "2017-04-20T12:42:19Z")

</div>

You can [Encrypt sensitive data in the user profile](http://Encrypt+sensitive+data+in+the+user+profile) in a Rule.

All users will have a user\_id, including social logins. Linking accounts will maintain the `user_id` of the _primary_ user, however the user\_id of the secondary user will still be available in the `user.identities` array. This is outlined here: [https://auth0.com/docs/link-accounts](https://auth0.com/docs/link-accounts)

---

<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:** [March 2, 2018, 5:53am UTC](https://community.auth0.com/t/auth0-database-store-vs-custom-database/6261/5 "2018-03-02T05:53:20Z")

</div>


