Nice and tidy solution for authenticate.