Modified login api to return error messages.