Пример #1
0
def first_login():
    if g.user is not None or 'user' not in session:
        flash(u'Something weird happened.')
        return redirect(url_for('.login'))

    if request.method == 'POST':
        if 'cancel' in request.form:
            del session['openid']
            flash(u'Login was aborted')
            return redirect(url_for('authentication.login'))

        user = User(session['openid'], request.form['name'], session['user']['email'])
        user.generate_verification_token()
        db_session.add(user)
        db_session.commit()

        mailer.send(
            UserVerificationMessage, to=user.email,
            user_id=user.id, verification_token=user.verification_token
        )
        flash(u'Successfully created profile and logged in')
        return redirect(oid.get_next_url())

    return render_template(
        'authentication/first_login.html',
        next=oid.get_next_url(),
        openid=session['openid']
    )
Пример #2
0
def first_login():
    if g.user is not None or 'user' not in session:
        flash(u'Something weird happened.')
        return redirect(url_for('.login'))

    if request.method == 'POST':
        if 'cancel' in request.form:
            del session['openid']
            flash(u'Login was aborted')
            return redirect(url_for('authentication.login'))

        user = User(session['openid'], request.form['name'],
                    session['user']['email'])
        user.generate_verification_token()
        db_session.add(user)
        db_session.commit()

        mailer.send(UserVerificationMessage,
                    to=user.email,
                    user_id=user.id,
                    verification_token=user.verification_token)
        flash(u'Successfully created profile and logged in')
        return redirect(oid.get_next_url())

    return render_template('authentication/first_login.html',
                           next=oid.get_next_url(),
                           openid=session['openid'])
Пример #3
0
 def storeAssociation(self, server_url, association):
     assoc = OpenIDAssociation(
         server_url=server_url,
         handle=association.handle,
         secret=association.secret.encode('base64'),
         issued=association.issued,
         lifetime=association.lifetime,
         assoc_type=association.assoc_type
     )
     db_session.add(assoc)
     db_session.commit()
Пример #4
0
def hotels_add():
    form = HotelForm()
    if form.validate_on_submit():
        hotel = Hotel()
        form.populate_obj(hotel)
        db_session.add(hotel)
        db_session.commit()
        flash('Hotel added.', 'success')
        return redirect(url_for('.hotels_index'))

    return render_template('admin/hotels/add.html', form=form)
Пример #5
0
def hotels_add():
    form = HotelForm()
    if form.validate_on_submit():
        hotel = Hotel()
        form.populate_obj(hotel)
        db_session.add(hotel)
        db_session.commit()
        flash('Hotel added.', 'success')
        return redirect(url_for('.hotels_index'))

    return render_template('admin/hotels/add.html', form=form)
Пример #6
0
 def useNonce(self, server_url, timestamp, salt):
     if abs(timestamp - time()) > nonce.SKEW:
         return False
     rv = OpenIDUserNonce.query.filter(
         (OpenIDUserNonce.server_url == server_url) &
         (OpenIDUserNonce.timestamp == timestamp) &
         (OpenIDUserNonce.salt == salt)
     ).first()
     if rv is not None:
         return False
     rv = OpenIDUserNonce(server_url=server_url, timestamp=timestamp,
                          salt=salt)
     db_session.add(rv)
     db_session.commit()
     return True