def to_python(self, value): if not ah.is_valid_external_id(value): err_msg = 'Invalid external identifier' _logger.error(err_msg, extra={'value': value}) error = routing.ValidationError(err_msg) error.args += (value,) raise error try: return ah.from_external_id(value) except ValueError: # Catch conversion errors so that the error handler can generate an appropriate response pass
def __new__(cls, value): return ah.from_external_id(value)
def _extract_auth_user_from_token_response(self, token_resp): content = self.extract_response_content(token_resp) self.assertIn('user_id', content, "login failed - missing 'user_id' in UserToken response") user_id = ah.from_external_id(content['user_id']) # Need to convert to our internal id self.assertIsNotNone(user_id, "login failed - missing value for 'user_id' in UserToken response") return provider.core_user_provider.get_user_by_id(user_id)