Authentication controller refactored