Exemplo n.º 1
0
def current_oauth_map_from_session_unsafe():

    # We have to use plain 'ole cookie handling before we switch over to a Flask-only
    # app, at which point we can strictly rely on Flask sessions.
    session_cookie_name = "session"
    session_cookie_value = cookie_util.get_cookie_value(session_cookie_name)
    if session_cookie_value and App.flask_secret_key:

        # Strip double quotes
        if session_cookie_value.startswith("\""):
            session_cookie_value = session_cookie_value[1:-1]

        # Fake little Flask request object to load up the Flask session cookie.
        fake_request = RequestMock(cookies={session_cookie_name: unicode(session_cookie_value)})

        # Flask's sessions are secured by the secret key.
        session_cookie = Session.load_cookie(fake_request, session_cookie_name, secret_key=App.flask_secret_key)
        if session_cookie and session_cookie.has_key("oam"):

            oauth_map_id = session_cookie["oam"]
            oauth_map = OAuthMap.get_by_id_safe(oauth_map_id)
            if oauth_map:
                return oauth_map

    return None
Exemplo n.º 2
0
def current_oauth_map_from_session_unsafe():

    # We have to use plain 'ole cookie handling before we switch over to a Flask-only
    # app, at which point we can strictly rely on Flask sessions.
    session_cookie_name = "session"
    session_cookie_value = cookie_util.get_cookie_value(session_cookie_name)
    if session_cookie_value and App.flask_secret_key:

        # Strip double quotes
        if session_cookie_value.startswith("\""):
            session_cookie_value = session_cookie_value[1:-1]

        # Fake little Flask request object to load up the Flask session cookie.
        fake_request = RequestMock(
            cookies={session_cookie_name: unicode(session_cookie_value)})

        # Flask's sessions are secured by the secret key.
        session_cookie = Session.load_cookie(fake_request,
                                             session_cookie_name,
                                             secret_key=App.flask_secret_key)
        if session_cookie and session_cookie.has_key("oam"):

            oauth_map_id = session_cookie["oam"]
            oauth_map = OAuthMap.get_by_id_safe(oauth_map_id)
            if oauth_map:
                return oauth_map

    return None
Exemplo n.º 3
0
    def get(self):
        """Render the register for new user page."""

        if (self.request_bool('under13', default=False)
                or cookie_util.get_cookie_value(auth.cookies.U13_COOKIE_NAME)):
            # User detected to be under13. Show them a sorry page.
            name = self.request_string('name', default=None)
            parent_registered = cookie_util.get_cookie_value('u13') == "subscribed"
            self.render_jinja2_template(
                    'under13.html', {
                            'name': name,
                            'parent_registered': parent_registered,
                    })
            return

        template_values = {
            'errors': {},
            'values': {},
            'google_url': users.create_login_url("/postlogin?completesignup=1"),
        }
        self.render_jinja2_template('signup.html', template_values)
Exemplo n.º 4
0
    def get(self):
        """Render the register for new user page."""

        if (self.request_bool('under13', default=False)
                or cookie_util.get_cookie_value(auth.cookies.U13_COOKIE_NAME)):
            # User detected to be under13. Show them a sorry page.
            name = self.request_string('name', default=None)
            parent_registered = cookie_util.get_cookie_value(
                'u13') == "subscribed"
            self.render_jinja2_template('under13.html', {
                'name': name,
                'parent_registered': parent_registered,
            })
            return

        template_values = {
            'errors': {},
            'values': {},
            'google_url':
            users.create_login_url("/postlogin?completesignup=1"),
        }
        self.render_jinja2_template('signup.html', template_values)
Exemplo n.º 5
0
 def get_cookie_value(key):
     return cookie_util.get_cookie_value(key)
Exemplo n.º 6
0
def get_xsrf_cookie_value():
    return cookie_util.get_cookie_value(XSRF_COOKIE_KEY)
Exemplo n.º 7
0
 def get_cookie_value(key):
     return cookie_util.get_cookie_value(key)
Exemplo n.º 8
0
def get_xsrf_cookie_value():
    return cookie_util.get_cookie_value(XSRF_COOKIE_KEY)