Exemplo n.º 1
0
def forgot():
	''' Forgot my password dialogue '''
	form = ForgottenPasswordForm(request.form)
	if request.method == 'POST' and form.validate():
		email = form.email.data,
		usersid = user.getUsersidByEmail(email)
		if usersid:
			u = user.getUserByID(usersid)
			reset_key = u.generatePasswordResetKey()
			queueEmail(
				usersid = usersid,
				subject = 'BubbleCK Password Reset',
				body = '''
Dear %s,
	You, or someone pretending to be you, has requested that your password for bubbleck.com be reset.  If you did not make this request, ignore this email.  Everything is fine.  If you did make this request, please visit %s%s to reset your password.
	Cheers,
		Taylor
					''' % (u.teachername, request.url_root[:-1], url_for('routes_user.passwordreset',reset_key=reset_key)),
				show_as_web_msg = False
			)
			flash('success|An email with instructions on how to reset your password has been sent to %s.' % email)
			return redirect(url_for('index'))
		else:
			flash('danger|No user is registered under email address (%s)' % email)
			return render_template('user/forgot.html', form=form)
	else:
		return render_template('user/forgot.html', form=form)
Exemplo n.º 2
0
def getUsersidByEmail(email=None):
	''' Get a userid by email ; called out by the client '''
	result = {}
	if email:
		usersid = user.getUsersidByEmail(email)
		if usersid:
			result['status'] = 'success'
			result['usersid'] = usersid
		else:
			result['status'] = 'error'
			result['message'] = 'No registered user has that email address'
	else:
		result['status'] = 'error'
		result['message'] = 'You did not supply an email address'
	return jsonify(**result)