Пример #1
0
def login():
    form = LoginForm(request.form);
    next = get_redirect_target()

    if next is None:
        next = url_for('main.index')

    if session.get('username', False):
        return redirect(url_for('main.index'))

    if form.validate_on_submit():
        user = request.form['username']
        password = request.form['password']

        if update_sources_from_context(current_app.config.geobox_state, user, password):
            session['username'] = user
            session.permanent = True
            current_app.config.geobox_state.config.set('user', 'name', user)
            current_app.config.geobox_state.config.write()
        else:
            flash(_('username or password not correct'), 'error')
            return redirect(url_for('user_view.login'))
        return redirect_back('main.index')

    return render_template('login.html', form=form, next=next)
Пример #2
0
def refresh_context():
    if update_sources_from_context(current_app.config.geobox_state, session['username'], request.form['password']):
        flash(_('load context document successful'), 'sucess')
    else:
        flash(_('password not correct'), 'error')

    return redirect(url_for('.admin'))
Пример #3
0
def login():
    form = LoginForm(request.form)
    next = get_redirect_target()

    if next is None:
        next = url_for('main.index')

    if session.get('username', False):
        return redirect(url_for('main.index'))

    if form.validate_on_submit():
        user = request.form['username']
        password = request.form['password']

        if update_sources_from_context(current_app.config.geobox_state, user,
                                       password):
            session['username'] = user
            session.permanent = True
            current_app.config.geobox_state.config.set('user', 'name', user)
            current_app.config.geobox_state.config.write()
        else:
            flash(_('username or password not correct'), 'error')
            return redirect(url_for('user_view.login'))
        return redirect_back('main.index')

    return render_template('login.html', form=form, next=next)
Пример #4
0
def refresh_context():
    if update_sources_from_context(current_app.config.geobox_state,
                                   session['username'],
                                   request.form['password']):
        flash(_('load context document successful'), 'sucess')
    else:
        flash(_('password not correct'), 'error')

    return redirect(url_for('.admin'))