Moved non-database functions from model to authentication library