Moved some logic to db.

* Added a view user_info, that is combination of users and api_secrets.
* Added a trigger on insertion on user_info, to insert values into the underlying tables.