Refactored authentications controller