Important security fix

Fixed authentication check