Logic for logging in/registering.