Fix authentication flow issues.