Пример #1
0
def adminlogin():
    form = Login()
    if form.validate_on_submit():
        u = Superuser.query.filter_by(username=form.username.data)
        if not u:
            flash('管理员不存在')
        elif u.check_password_hash(form.password.data):
            flash('登录成功!')
            login_user(u, remember=form.remember.data)
        else:
            flash('请输入正确的密码')
    return render_template('superuser/login.html', form=form)
Пример #2
0
def login():
    form = Login()
    if form.validate_on_submit():
        username = user.query.filter_by(email=form.email.data).first()
        print(
            username,
            bcrypt.check_password_hash(username.password, form.password.data))
        if username and bcrypt.check_password_hash(username.password,
                                                   form.password.data):
            login_user(username, remember=True)
            return redirect(url_for('home'))
        else:
            flash('Login unsuccessful. Please check email and password.')
    return render_template("login.html", form=form)
Пример #3
0
def login():
    form = Login()
    if form.validate_on_submit():
        u = User.query.filter_by(username=form.username.data).first()
        if not u.check_password(form.userpass.data):
            flash('请输入正确的密码')
        else:
            u.lastLogin = datetime.utcnow()
            u.save()
            flash('登陆成功!!!')
            cache.clear()
            login_user(u, remember=form.remember.data)
            return redirect(url_for('main.index'))
    return render_template('user/login.html',form=form)
Пример #4
0
def login():
    form = Login()
    if form.validate_on_submit():
        u = User.query.filter_by(username=form.username.data).first()
        if not u:
            flash('该用户不存在')
        elif not u.confirm:
            flash('该用户还没激活!!!')
        elif u.check_password_hash(form.password.data):
            flash('登录成功!')
            login_user(u, remember=form.remember.data)
            return redirect(url_for('main.index'))
        else:
            flash('请输入正确的密码')
    return render_template('user/login.html', form=form)
Пример #5
0
def login():
    form = Login()
    if form.validate_on_submit():
        u = User.query.filter_by(username=form.username.data).first()
        if not u.check_password(form.password.data):
            flash('请输入正确的密码')
        elif not u.confirm:
            flash('该账户未激活 请前往激活')
        else:
            u.lastLogin = datetime.utcnow()
            u.save()
            flash('登录成功!!')
            login_user(u, remember=form.remember.data)
            return redirect(request.args.get('prevpath', '/'))  # 返回到上一个页面
    return render_template('user/login.html', form=form)
Пример #6
0
def login():
    form = Login()
    if form.validate_on_submit():
        u = User.query.filter(
            or_(User.username == form.username.data,
                User.email == form.username.data)).first()
        if not u.confirm:
            return '该用户还没有激活,请激活后登录'
        elif not u.check_password(form.userpass.data):
            return '密码输入错误'
        else:
            flash('登录成功,欢迎' + u.username)
            login_user(u)
            return redirect(url_for('main.index'))
    return render_template('user/login.html', form=form)
Пример #7
0
def login():
    form = Login()
    if form.validate_on_submit():
        u = User.query.filter_by(username=form.username.data).first()
        print(u)
        if not u:
            flash('当前用户不存在')
        elif not u.confirm:
            flash('您还没有进行账户的激活')
        elif u.check_password(form.userpass.data):
            flash('登录成功!欢迎'+u.username)
            login_user(u)
            return redirect(url_for('main.index')) #重定向到首页
        else:
            flash('请输入正确的密码')
    return render_template('user/login.html',form=form)
Пример #8
0
def login():
    form = Login()
    if form.validate_on_submit():
        u = User.query.filter_by(username=form.username.data).first()
        if not u:
            flash('当前用户不存在')
        elif not u.confirm:
            flash('当前用户未激活')
        elif not u.check_password(form.userpass.data):
            flash('请输入正确的密码')
        else:
            # pass #处理登录 状态保持
            login_user(u)
            flash('登录成功')
            return redirect(request.args.get('next',url_for('main.index')))
    return render_template('user/login.html',form=form)
Пример #9
0
def login():
    form = Login()
    if form.validate_on_submit():
        u = User.query.filter(User.username == form.username.data).first()
        if not u:
            flash('请输入正确的用户名')
        elif not u.check_password(form.userpass.data):
            flash('密码有误,请输入正确的密码...')
        elif u.status != '专家':
            flash('您不是专家哦~')
        else:
            # 修改登录时间
            u.lastLogin = datetime.now()
            u.save()
            login_user(u, remember=form.remember.data)  # 使用第三方扩展库处理登录状态的维持
            return redirect(url_for('expert.main_page'))
    return render_template('expert/login.html', form=form)
Пример #10
0
def login():
    form = Login()
    if form.validate_on_submit():
        u = User.query.filter_by(username=form.username.data)
        if not u:
            flash('当前用户不存在')
        elif not u.confirm:
            flash('未激活')
        elif not u.check_password(form.userpass.data):
            flash('请输入正确的密码')
        else:
            pass
            logout_user(u)
            flash('登录成功')
            return redirect(url_for('main.index'))

    return render_template('user/login.html', form=form)
Пример #11
0
def login():
    form = Login()
    if form.validate_on_submit():
        u = User.query.filter(User.username == form.username.data).first()
        if not u:
            flash('请输入正确的用户名或密码')
        elif not u.confirm:
            flash('您还没有激活 请前去激活账户')
            return redirect(url_for('user.again_active'))
        elif not u.check_password(form.userpass.data):
            flash('请输入正确的用户名或密码')
        else:
            flash('登录成功')
            # 修改登录时间
            u.lastLogin = datetime.now()
            u.save()
            login_user(u, remember=form.remember.data)  # 使用第三方扩展库处理登录状态的维持
            return redirect(url_for('main.index'))

    return render_template('user/login.html', form=form)
Пример #12
0
def login():
    form = Login()
    if form.validate_on_submit():
        u = User.query.filter_by(username=form.username.data).first()
        if not u:
            flash('当前用户不存在')
        elif not u.confirm:
            flash('你的账户未激活')
        elif u.check_password(form.userpass.data):
            flash('登录成功,欢迎'+u.username)
            login_user(u)#维护登录对象u
            cache.clear()
            u.lastlogin_date_cache = datetime.utcnow()+timedelta(hours=8)
            u.save()
            return redirect(url_for('main.index'))
        else:
            flash('请输入正确的密码')
        # return render_template('')
    #############################################
    c = Course.query.filter_by(pid=0)
    c1 = Course.query.filter(and_(Course.path.endswith(','), Course.pid != 0))
    c2 = Course.query.filter(and_(not_(Course.path.endswith(',')), Course.pid != 0))
    return render_template('user/login.html',form=form,course=c,course1=c1,course2=c2)