Fixed authentication logic