Fixing bug in iOS authenticate