コード例 #1
0
def reset_password_post(token):
    email = validate_token(app.config, token)
    if email:
        user = User.objects(email=email).first()
        if user:
            form = PasswordForm(request.forms)
            if form.validate():
                user.password = user.generate_password(form.password.data)
                user.save()
                redirect('/reset_password_success')
            return {'form': PasswordForm(), 'token': token}
    abort(404)
コード例 #2
0
ファイル: users.py プロジェクト: david-xie/daimaduan.com
def reset_password_post(token):
    email = validate_token(app.config, token)
    if email:
        user = User.objects(email=email).first()
        if user:
            form = PasswordForm(request.forms)
            if form.validate():
                user.password = user.generate_password(form.password.data)
                user.save()
                redirect('/reset_password_success')
            return {'form': PasswordForm(), 'token': token}
    abort(404)
コード例 #3
0
def reset_password_get(token):
    email = validate_token(app.config, token)
    if email:
        user = User.objects(email=email).first()
        if user:
            return {'form': PasswordForm(), 'token': token}
    abort(404)
コード例 #4
0
ファイル: sites.py プロジェクト: myideaway1024/daimaduan.com
def reset_password(token):
    if request.method == 'GET':
        email = validate_token(current_app.config, token)
        if email:
            user = User.objects(email=email).first()
            if user:
                return render_template('user/reset_password.html',
                                       form=PasswordForm(),
                                       token=token)
        abort(404)
    else:
        email = validate_token(current_app.config, token)
        if email:
            user = User.objects(email=email).first()
            if user:
                form = PasswordForm()
                if form.validate_on_submit():
                    user.password = user.generate_password(form.password.data)
                    user.save()
                    return redirect('/reset_password_success')
                return render_template('user/reset_password.html',
                                       form=PasswordForm(),
                                       token=token)
        abort(404)
コード例 #5
0
ファイル: sites.py プロジェクト: wujunze/daimaduan.com
def reset_password(token):
    if request.method == 'GET':
        email = validate_token(current_app.config, token)
        if email:
            user = User.objects(email=email).first()
            if user:
                return render_template('users/reset_password.html',
                                       form=PasswordForm(),
                                       token=token)
        abort(404)
    else:
        email = validate_token(current_app.config, token)
        if email:
            user = User.objects(email=email).first()
            if user:
                form = PasswordForm(request.form)
                if form.validate_on_submit():
                    user.password = user.generate_password(form.password.data)
                    user.save()
                    return redirect('/reset_password_success')
                return render_template('users/reset_password.html',
                                       form=PasswordForm(),
                                       token=token)
        abort(404)