def post(self): form = EmailForm() if form.validate_on_submit(): self._send_mail(form.email.data) return redirect(url_for("views.index")) else: flash_errors(form) return render_template("www/forget_password.html", form=form)
def post(self): form = SignupForm() if form.validate_on_submit(): account = AccountModel(email=form.email.data, password=form.password.data) db.session.add(account) db.session.commit() self._send_mail(account.email) return redirect(url_for(".index")) else: flash_errors(form) return render_template("www/register.html", form=form)
def post(self): form = LoginForm() if form.validate_on_submit(): account = AccountModel.query.filter_by(email=form.email.data).first_or_404() if account.is_correct_password(form.password.data): login_user(account) return redirect(url_for("admin.index")) else: flash("密码不正确") else: flash_errors(form) return render_template("www/login.html", form=form)
def post(self, token): try: email = ts.loads(token, salt=app.config["MAIL_RESET_SALT"], max_age=app.config["MAIL_RESET_MAX_AGE"]) except: abort(404) form = PasswordForm() if form.validate_on_submit(): account = AccountModel.query.filter_by(email=email).first_or_404() account.password = form.password.data db.session.commit() return redirect(url_for("views.login")) else: flash_errors(form) return render_template("www/reset_with_token.html", form=form, token=token)