コード例 #1
0
def login():
    if current_user.is_authenticated:
        return redirect(url_for('home'))
    form = LoginForm()
    if form.validate_on_submit():
        user = User.query.filter_by(email=form.email.data).first()
        if user and bcrypt.check_password_hash(user.password,
                                               form.password.data):
            login_user(user)
            return redirect(url_for('home'))
        else:
            flash('Login unsuccessful. Please check email and password',
                  'danger')
    return render_template('login.html', title='Login', form=form)
コード例 #2
0
ファイル: routes.py プロジェクト: DavidRuoyuWu/316project
def login():
	form = LoginForm()
	if current_user.is_authenticated:
		return redirect(url_for('main'))
	if form.validate_on_submit():
		user = User.query.filter_by(email=form.email.data).first()
		# check if login email and pw is ocrrect
		if user and bcrypt.check_password_hash(user.password, form.password.data):
			login_user(user, remember=form.remember.data)
			next_page = request.args.get('next')
			return redirect(next_page) if next_page else redirect(url_for('main'))
		else:
			flash('Login Unsuccessful. Please check email and password', 'danger')
	return render_template('login.html', title='Login', form=form)
コード例 #3
0
ファイル: routes.py プロジェクト: ddiatlov/scheduler
def login():
    if current_user.is_authenticated and current_user.is_active:
        return redirect(url_for('home'))

    form = LoginForm()
    if form.validate_on_submit():
        user_name = User.query.filter_by(username=form.username.data).first()
        if user_name and bcrypt.check_password_hash(user_name.password, form.password.data):
            login_user(user_name, remember=form.remember.data)
            next_page = request.args.get('next')
            return redirect(next_page) if next_page else redirect(url_for('home'))
        else:
            flash('Login Unsuccessful. Please contact your IT Administrator.', 'danger')
    return render_template('login.html',
                           title='Login',
                           form=form)