refactored to divide authentication functions to controllers.Authentication