Exemple #1
0
    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
Exemple #2
0
    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
Exemple #3
0
    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
Exemple #4
0
    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
Exemple #5
0
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