def resend_confirm_email(): if current_user.confirmed: return redirect(url_for('main.index')) token = generate_token(user=current_user, operation=Operations.CONFIRM) send_confirm_email(user=current_user, token=token) flash('New email sent, check your inbox.', 'info') return redirect(url_for('main.index'))
def change_email_request(): form = ChangeEmailForm() if form.validate_on_submit(): # 发送验证邮件 token = generate_token(user=current_user, operation=Operations.CHANGE_EMAIL, new_email=form.email.data.lower()) send_confirm_email(to=form.email.data, user=current_user, token=token, change_email=True) flash('Confirm email sent, check your inbox.', 'info') return redirect(url_for('.index', username=current_user.username)) form.email.data = current_user.email return render_template('user/settings/change_email.html', form=form)
def resend_confirm_email(): """ 重新发送确认邮件 :return: """ if current_user.confirmed: return redirect(url_for('main.index')) token = generate_token(user=current_user, operation=Operations.CONFIRM) send_confirm_email(user=current_user, token=token) flash("New email send, check your inbox ", 'info') return redirect(url_for("main.index"))
def register(): if current_user.is_authenticated: return redirect(url_for('main.index')) form = RegisterForm() if form.validate_on_submit(): name = form.name.data email = form.email.data username = form.username.data password = form.password.data user = User(name=name, email=email, username=username) user.set_password(password) db.session.add(user) db.session.commit() token = generate_token(user=user, operation='confirm') send_confirm_email(user=user, token=token) flash('Confirm email sent, pls sheck you inbox', 'info') return redirect(url_for('auth.login')) return render_template('auth/register.html', form=form)
def register(): if current_user.is_authenticated: return redirect(url_for("main.index")) form = RegisterForm() if form.validate_on_submit(): name = form.name.data email = form.email.data.lower() # 小写处理 username = form.username.data password = form.password.data user = User(name=name, email=email, username=username) user.set_password(password) # 设置密码 db.session.add(user) db.session.commit() token = generate_token(user=user, operation=Operations.CONFIRM) send_confirm_email(user=user, token=token) flash("Confirm email sent ,check your inbox.", 'info') return redirect(url_for('auth.login')) return render_template("auth/register.html", form=form)