refactor authentication controller