Пример #1
0
def user_loader(email):
	"""The user loader implemented by Flask-Login loads a user via email."""
	if not backend.emailAlreadyInUse(email):
		return
	else:
		user = User().loadUser(email)
		user.id = email
		return user
Пример #2
0
def start():
	"""START: On this page users enter the information which the application will use to route them their event information."""
	form = forms.StartForm(csrf_enabled=False)
	if request.method == 'GET':
		return render_template('start.html', form=form)
	else:
		if request.form['password'] and request.form['email'] and request.form['i1'] and request.form['i2'] and request.form['i3']:
			if backend.emailAlreadyInUse(request.form['email']):
				return render_template('start.html', form=form, error='Error: The email you have chosen is already in use.')
			elif 'baruch' not in request.form['email']:
				return render_template('start.html', form=form, error='Error: Please input a Baruch email, only, please! Other email addresses are not supported yet.')
				# TODO: To support other email addresses we can use the flask-wtf validate email subroutine.
			else:
				user = User(email=request.form['email'], password=request.form['password'])
				concepts = [concept for concept in [request.form['i1'], request.form['i2'], request.form['i3'], request.form['i4'], request.form['i5']] if concept != '']
				for concept in concepts:
					user.addUserInputToConceptModel(concept)
				user.saveUser()
				flask_login.login_user(user)
				flash('Your account was successfully registered.')
				return render_template('registered.html')
		else:
			return render_template('start.html', form=form, error='Error: You must input all of the required fields.')