Example #1
0
    def login_view(self):
        """This is an override of the login view that comes from the
        persona plugin. The basics of verify_login and remembering the
        user in a cookie are still present.

        Here we check to see if the user has been created in the
        database, then create the user. If they are an existing user,
        we just take them to the page they were trying to access.
        """
        email = verify_login(self.request)
        headers = remember(self.request, email)
        # Check to see if the user exists
        user = DBSession.query(TodoUser).filter(
            TodoUser.email == email).first()
        if user and user.profile_complete:
            self.request.session.flash('Logged in successfully')
            return HTTPFound(self.request.POST['came_from'], headers=headers)
        elif user and not user.profile_complete:
            msg = "Before you begin, please update your profile."
            self.request.session.flash(msg, queue='info')
            return HTTPFound('/account', headers=headers)
        # Otherwise, create an account and optionally create some content
        settings = self.request.registry.settings
        generate_content = asbool(
            settings.get('todopyramid.generate_content', None))
        # Create the skeleton user
        with transaction.manager:
            DBSession.add(TodoUser(email))
            if generate_content:
                create_dummy_content(email)
        msg = ("This is your first visit, we hope your stay proves to be "
               "prosperous. Before you begin, please update your profile.")
        self.request.session.flash(msg)
        return HTTPFound('/account', headers=headers)
Example #2
0
def login(request):
    email = verify_login(request)
    request.response.headers = remember(request, email)
    if email not in KNOWN:
        KNOWN.add(email)
        print(email, 'just logged in for the first time')
        return {'redirect': '/welcome'}
    else:
        return {'redirect': request.POST['came_from']}
Example #3
0
def login(request):
    email = verify_login(request)
    if email == '*****@*****.**':
        return {'redirect': request.POST['came_from'], 'success': False}

    request.response.headers = remember(request, email)
    if email not in KNOWN:
        KNOWN.add(email)
        print(email, 'just logged in for the first time')
        return {'redirect': '/welcome', 'success': True}
    else:
        return {'redirect': request.POST['came_from'], 'success': True}
Example #4
0
def login(request):
    email = verify_login(request)
    if email == '*****@*****.**':
        return {'redirect': request.POST['came_from'], 'success': False}

    request.response.headers = remember(request, email)
    if email not in KNOWN:
        KNOWN.add(email)
        print(email, 'just logged in for the first time')
        return {'redirect': '/welcome', 'success': True}
    else:
        return {'redirect': request.POST['came_from'], 'success': True}
Example #5
0
def login(request):
    email = verify_login(request)

    request.response.headers = remember(request, email)
    if email not in KNOWN:
        cursor = connection.cursor()
        cursor.execute("INSERT INTO users (email) VALUES (%s);", (email,))
        connection.commit()
        KNOWN.add(email)
        return {'redirect': '/welcome', 'success': True}
    else:
        return {'redirect': request.POST['came_from'], 'success': True}
Example #6
0
def login(request):
    # Verify the assertion and get the email of the user
    persona_email = verify_login(request)

    # Check that the email exists in the players table
    player_email = DBSession.query(Player).\
            filter(Player.email_addr == persona_email).one()

    #log.debug("Verified email address: %s" % persona_email)
    #log.debug("Corresponding player is %s" % player_email)

    if player_email is not None:
        # Add the headers required to remember the user to the response
        request.response.headers.extend(remember(request, persona_email))
    else:
        url = request.route_path("forbidden")
        return HTTPFound(location=url)

    # Return a json message containing the address or path to redirect to.
    return {'redirect': request.POST['came_from'], 'success': True}
Example #7
0
def login_view(request):
    # Verify the assertion and get the email of the user
    email = verify_login(request).lower()

    # Add the headers required to remember the user to the response
    request.response.headers.extend(remember(request, email))

    try:
        user = db.query(User).filter(User.email == email).one()
        request.session.flash('User signed in.', queue='info')
        # Return a json message containing the address or path to redirect to.
        return {'redirect': request.POST['came_from'],
                'success': True
                }
    except NoResultFound:
        request.session.flash('New user detected.', queue='info')
        # Return a json message containing the path to the registration page.
        return {'redirect': resource_path(userregister),
                'success': True
                }
Example #8
0
def login(request):
    # Verify the assertion and get the email of the user
    persona_email = verify_login(request)

    # Check that the email exists in the players table
    player_email = DBSession.query(Player).\
            filter(Player.email_addr == persona_email).one()

    #log.debug("Verified email address: %s" % persona_email)
    #log.debug("Corresponding player is %s" % player_email)

    if player_email is not None:
        # Add the headers required to remember the user to the response
        request.response.headers.extend(remember(request, persona_email))
    else:
        url = request.route_url("forbidden")
        return HTTPFound(location=url)

    # Return a json message containing the address or path to redirect to.
    return {'redirect': request.POST['came_from'], 'success': True}
Example #9
0
    def login_view(self):
        """This is an override of the login view that comes from the
        persona plugin. The basics of verify_login and remembering the
        user in a cookie are still present.

        Here we check to see if the user has been created in the
        database, then create the user. If they are an existing user,
        we just take them to the page they were trying to access.
        """
        email = verify_login(self.request)
        headers = remember(self.request, email)
        # Check to see if the user exists
        user = DBSession.query(TodoUser).filter(
            TodoUser.email == email).first()
        if user and user.profile_complete:
            self.request.session.flash('Logged in successfully')
            return HTTPFound(self.request.POST['came_from'], headers=headers)
        elif user and not user.profile_complete:
            msg = "Before you begin, please update your profile."
            self.request.session.flash(msg, queue='info')
            return HTTPFound('/account', headers=headers)
        # Otherwise, create an account and optionally create some content
        settings = self.request.registry.settings
        generate_content = asbool(
            settings.get('todopyramid.generate_content', None)
        )
        # Create the skeleton user
        with transaction.manager:
            DBSession.add(TodoUser(email))
            if generate_content:
                create_dummy_content(email)
        msg = (
            "This is your first visit, we hope your stay proves to be "
            "prosperous. Before you begin, please update your profile."
        )
        self.request.session.flash(msg)
        return HTTPFound('/account', headers=headers)