コード例 #1
0
ファイル: views.py プロジェクト: akfork/wifidog-auth-flask
def wifidog_login():
    form = LoginVoucherForm(flask.request.form)

    if form.validate_on_submit():
        voucher_id = form.voucher.data.upper()
        voucher = Voucher.query.get(voucher_id)

        form.populate_obj(voucher)
        voucher.token = generate_token()
        db.session.commit()

        flask.session['voucher_token'] = voucher.token

        # flask.flash('Logged in, continue to <a href="%s">%s</a>' % (form.url.data, form.url.data), 'success')

        url = 'http://%s:%s/wifidog/auth?token=%s' % (
            voucher.gw_address, voucher.gw_port, voucher.token)
        return flask.redirect(url)

    if flask.request.method == 'GET':
        gateway_id = flask.request.args.get('gw_id')
    else:
        gateway_id = form.gateway_id.data

    if gateway_id is None:
        flask.abort(404)

    gateway = Gateway.query.filter_by(id=gateway_id).first_or_404()
    return flask.render_template('wifidog/login.html',
                                 form=form,
                                 gateway=gateway)
コード例 #2
0
def wifidog_login():
    form = LoginVoucherForm(flask.request.form)

    if form.validate_on_submit():
        voucher_id = form.voucher.data.upper()
        voucher = Voucher.query.get(voucher_id)

        form.populate_obj(voucher)
        voucher.token = generate_token()
        db.session.commit()

        voucher_logged_in.send(flask.current_app._get_current_object(), voucher=voucher)

        url = 'http://%s:%s/wifidog/auth?token=%s' % (voucher.gw_address, voucher.gw_port, voucher.token)
        print url

        return flask.redirect(url)

    if flask.request.method == 'GET':
        gateway_id = flask.request.args.get('gw_id')
    else:
        gateway_id = form.gateway_id.data

    if gateway_id is None:
        flask.abort(404)

    gateway = Gateway.query.filter_by(id=gateway_id).first_or_404()
    return flask.render_template('wifidog/login.html', form=form, gateway=gateway)
コード例 #3
0
ファイル: views.py プロジェクト: akfork/wifidog-auth-flask
def wifidog_login():
    form = LoginVoucherForm(flask.request.form)

    if form.validate_on_submit():
        voucher_id = form.voucher.data.upper()
        voucher = Voucher.query.get(voucher_id)

        form.populate_obj(voucher)
        voucher.token = generate_token()
        db.session.commit()

        flask.session['voucher_token'] = voucher.token

        # flask.flash('Logged in, continue to <a href="%s">%s</a>' % (form.url.data, form.url.data), 'success')

        url = 'http://%s:%s/wifidog/auth?token=%s' % (voucher.gw_address, voucher.gw_port, voucher.token)
        return flask.redirect(url)

    if flask.request.method == 'GET':
        gateway_id = flask.request.args.get('gw_id')
    else:
        gateway_id = form.gateway_id.data

    if gateway_id is None:
        flask.abort(404)

    gateway = Gateway.query.filter_by(id=gateway_id).first_or_404()
    return flask.render_template('wifidog/login.html', form=form, gateway=gateway)