当前位置: 首页>>代码示例>>Python>>正文


Python UserData.get_from_user_id方法代码示例

本文整理汇总了Python中models.UserData.get_from_user_id方法的典型用法代码示例。如果您正苦于以下问题:Python UserData.get_from_user_id方法的具体用法?Python UserData.get_from_user_id怎么用?Python UserData.get_from_user_id使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在models.UserData的用法示例。


在下文中一共展示了UserData.get_from_user_id方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _consume_auth_token

# 需要导入模块: from models import UserData [as 别名]
# 或者: from models.UserData import get_from_user_id [as 别名]
    def _consume_auth_token(self):
        """Check to see if a valid auth token is specified as a param
        in the request, so it can be converted into a cookie
        and used as the identifier for the current and future requests.
        """

        auth_stamp = self.request_string("auth")
        if auth_stamp:
            # If an auth stamp is provided, it means they logged in using
            # a password via HTTPS, and it has redirected here to postlogin
            # to set the auth cookie from that token. We can't rely on
            # UserData.current() yet since no cookies have yet been set.
            token = AuthToken.for_value(auth_stamp)
            if not token:
                logging.error("Invalid authentication token specified")
            else:
                user_data = UserData.get_from_user_id(token.user_id)
                if not user_data or not token.is_valid(user_data):
                    logging.error("Invalid authentication token specified")
                else:
                    # Good auth stamp - set the cookie for the user, which
                    # will also set it for this request.
                    auth.cookies.set_auth_cookie(self, user_data, token)
                    return True
        return False
开发者ID:PaulWagener,项目名称:khan-website,代码行数:27,代码来源:login.py

示例2: get_user_data

# 需要导入模块: from models import UserData [as 别名]
# 或者: from models.UserData import get_from_user_id [as 别名]
    def get_user_data(self):
        from models import UserData

        user_id = None
        email = None

        if self.uses_google():
            user_id, email = get_google_user_id_and_email_from_oauth_map(self)
        elif self.uses_facebook():
            user_id = get_facebook_user_id_from_oauth_map(self)
            email = user_id

        user_data = UserData.get_from_user_id(user_id) or \
                    UserData.get_from_db_key_email(email) or \
                    UserData.insert_for(user_id, email)

        return user_data
开发者ID:KhanWorld,项目名称:KhanAcademy,代码行数:19,代码来源:auth_models.py

示例3: retrieve_identity

# 需要导入模块: from models import UserData [as 别名]
# 或者: from models.UserData import get_from_user_id [as 别名]
def retrieve_identity(user_id):
    from models import UserData
    user_data = UserData.get_from_user_id(user_id)
    return user_data.gae_bingo_identity if user_data else None
开发者ID:avh4,项目名称:khan-academy,代码行数:6,代码来源:config.py


注:本文中的models.UserData.get_from_user_id方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。