Beispiel #1
0
def register_post():
	error = "Can't leave any fields blank"
	form = RegistrationForm(request.form)
	if form.validate():
		new_user = User()
		form.populate_obj(new_user)
		if new_user.create():
			flash('Registration successful!')
			return redirect(url_for('user.index'))
		else:
			error = "User already exists"
	return render_template('register.html', form=form, error=error, title='Register')	
Beispiel #2
0
def login_user(form):
	user = User.objects(username=request.form['username'], password=request.form['password'])
	if len(user) == 1:
		user = user.get()
		session['username'] = request.form['username']
		session.pop('isadmin', None)
		flash('Login successful!')
		return redirect(_role_specific_url(user))
	return render_template('index.html', form=form, error='Invalid username or password', title='Home')