def resend_confirmation(): """ Get a new confirmation token (if expired or if mail was lost). """ if current_user.confirmed: flash(u"Your account is already confirmed.") return next_or_index() token = current_user.generate_confirmation_token() email.confirm(current_user, token) flash(u"A new confirmation link has been sent to you. Please check email.") return to_dashboard()
def signup(): """ Signup view. If GET or ValidationError, render 'auth/signup.html'. If valid POST, add to database and send confirmation email. """ form = SignupForm() if form.validate_on_submit(): user = User(email=form.email.data, username=form.username.data, password=form.password.data) db.session.add(user) db.session.commit() token = user.generate_confirmation_token() email.confirm(user, token) flash(u"A confirmation link has been sent to you. Please check email.") login_user(user) return to_dashboard() return auth_form(form, signup=True)