def remember_identity(self, result, userid=None): """stores authomatic result data """ if userid is None: # create a new userid userid = new_userid(self, result) useridentities = UserIdentities(userid) self._useridentities_by_userid[userid] = useridentities else: # use existing userid useridentities = self._useridentities_by_userid.get(userid, None) if useridentities is None: raise ValueError('Invalid userid') provider_id = self._provider_id(result) if provider_id in self._userid_by_identityinfo and self._userid_by_identityinfo[ provider_id] != userid: # This provider's identity is already registered for other user raise ValueError( "Your %s account is already linked with other id. \ Please login and unlink first." % provider_id[0]) if provider_id not in self._userid_by_identityinfo: self._userid_by_identityinfo[provider_id] = userid useridentities.handle_result(result) return useridentities
def make_user(login, testcase=None, password=None): from pas.plugins.authomatic.useridentities import UserIdentities uis = UserIdentities(login) if password: uis._secret = password if testcase: testcase.plugin._useridentities_by_userid[login] = uis mock_result = MockResult(provider=MockResult(name='mock_provider'), user=MockResult()) uis.handle_result(mock_result) return uis
def make_user(login, testcase=None, password=None): from pas.plugins.authomatic.useridentities import UserIdentities uis = UserIdentities(login) if password: uis._secret = password if testcase: testcase.plugin._useridentities_by_userid[login] = uis mock_result = MockResult( provider=MockResult(name='mock_provider'), user=MockResult() ) uis.handle_result(mock_result) return uis
def remember_identity(self, result, userid=None): """stores authomatic result data""" if userid is None: # create a new userid userid = new_userid(self, result) useridentities = UserIdentities(userid) self._useridentities_by_userid[userid] = useridentities else: # use existing userid useridentities = self._useridentities_by_userid.get(userid, None) if useridentities is None: raise ValueError("Invalid userid") provider_id = self._provider_id(result) if provider_id not in self._userid_by_identityinfo: self._userid_by_identityinfo[provider_id] = userid useridentities.handle_result(result) return useridentities
def remember_identity(self, result, userid=None): """stores authomatic result data """ if userid is None: # create a new userid userid = new_userid(self, result) useridentities = UserIdentities(userid) self._useridentities_by_userid[userid] = useridentities else: # use existing userid useridentities = self._useridentities_by_userid.get(userid, None) if useridentities is None: raise ValueError('Invalid userid') if self._provider_id(result) not in self._userid_by_identityinfo: self._userid_by_identityinfo[self._provider_id(result)] = userid useridentities.handle_result(result) return useridentities