Fixing authentication flow deadlock