Moved the authentication logic to the global object.