Using database for user authentication