Updated login system to handle multiple login sources. Updated for new database schema.