def register(): """Register route.""" form = RegistationForm() if form.validate_on_submit(): token = random_str(30) name = request.form['name'] email = request.form['email'] password = request.form['password'] db.session.add(User(name, email, password, token)) db.session.commit() reset_url = url_for('users.confirm_account', token=token, _external=True) send_registration( { 'to': email, 'subject': 'Project confirmation email' }, values=[ name, reset_url, reset_url ] ) flash('Thanks for signing up. Please check your email to for a' ' confirmation link so we know you\'re human.', 'info') resend_url = url_for('.resend_confirmation') + '?email=' + email flash('If you do not revieve your confirmation email you can resend ' 'it by clicking <a href="' + resend_url + '">here</a>', 'info') return redirect(url_for('users.login')) return render_template('register.html', form=form)
def resend_confirmation(): email = request.args.get('email', None) if email is None: abort(404) user = User.query.filter_by(email=email).first() reset_url = url_for('users.confirm_account', token=user.token, _external=True) send_registration( { 'to': email, 'subject': 'Project confirmation email' }, values=[ user.name, reset_url, reset_url ] ) flash('Your email confirmation has been resent. Please check your inbox.', 'info') return redirect(url_for('users.login'))