如何在flask-seurity中覆盖custom_mail发送方法

时间:2016-11-09 06:38:18

标签: python flask-security

我想在我的项目中实现flask-security。当用户在app上注册时,他会收到邮件进行确认。然后他会关注链接,但会重定向到基本视图而不是覆盖自定义视图。

代码

@app.route('/confirm_demo/<token>')
                @login_required
                def confirm_email_demo(token):
                    print "My Method........................................."
                    try:  
                        email = confirm_token(token)
                    except:
                        flash('The confirmation link is invalid or has expired.', 'danger')
                    user = User.query.filter_by(email=email).first_or_404()
                    if user.active:
                        flash('Account already confirmed. Please login.', 'success')
                    else:
                        user.active = True
                        user.confirmed_at = datetime.datetime.now()
                        db.session.add(user)
                        db.session.commit()
                        flash('You have confirmed your account. Thanks!', 'success')
                    return redirect(url_for('main.home'))

0 个答案:

没有答案