Ejemplo n.º 1
0
def start_auth():
    user_auth_task_id = ''
    auth_success = False
    user_uid = ''
    form = LoginForm(request.form, csrf_enabled=False)
    if request.method == 'POST' and form.validate():
        user_uid = form.uid.data
        user = User.query.filter_by(uid=user_uid).first()
        print user
        user_auth_task = auth.delay(user, user_uid, form.password.data)
        user_auth_task_id = user_auth_task.task_id
    return jsonify(task_id=user_auth_task_id, user_uid=user_uid)
Ejemplo n.º 2
0
def login():
    auth_success = False
    ldap_invalid_credentials = False
    ldap_server_down = False
    form = LoginForm(request.form)
    if form.validate_on_submit():
        uid = form.uid.data
        user = User.query.filter_by(uid=uid).first()
        print user
        auth_success = user_auth(user, uid, form.password.data)
        if auth_success:
            if user == None:
                user = User.query.filter_by(uid=uid).first()
            session['user_id'] = user.id
            flash('Welcome %s' % user.common_name)
            login_user(user)
            identity_changed.send(current_app._get_current_object(), identity=Identity(user.id))
            return redirect(url_for('users.home'))
        flash('Wrong UID', 'error-message')
    return render_template('users/login.html', form=form)