예제 #1
0
파일: auth.py 프로젝트: eaudeweb/eea.ecosys
def login():
    form = LoginForm()
    if form.validate_on_submit():
        username, password = request.form['username'], request.form['password']
        username = username.lower().strip()
        if plugldap.login_user(username, password):
            user, created = get_user(username)
            flask_login.login_user(user)
            flash('Logged in successfully as %s %s (%s).' %
                  (user.first_name, user.last_name, user.id))
            user.last_login = datetime.datetime.utcnow()
            user.save(safe=False)
            if created or not user.country:
                resp = redirect(url_for('.profile',
                                        next=request.args.get('next', '')))
            else:
                resp = redirect(request.args.get("next") or
                                url_for('library.home'))
            resp.set_cookie("__ac",
                            base64.b64encode("%s:%s" % (username, password)))
            return resp
        else:
            flash('Bad username or password.')

    return render_template('login.html', form=form)
예제 #2
0
파일: auth.py 프로젝트: sandriu/eea.ecosys
def login():
    form = LoginForm()
    if form.validate_on_submit():
        username, password = request.form['username'], request.form['password']
        if plugldap.login_user(username, password):
            user = get_user(username)
            flask_login.login_user(user)
            flash('Logged in successfully.')
            return redirect(request.args.get("next") or url_for('library.home'))
        else:
            flash('Bad username or password.')
    return render_template('login.html', form=form)