csrf jquery ajax testing part 1

This commit is contained in:
Xevion
2019-07-04 11:59:42 -05:00
parent 9273a82814
commit 94a7a6a9ff
3 changed files with 24 additions and 9 deletions

View File

@@ -1,4 +1,5 @@
from app import app, db, login
from app.forms import ProfileSettingsForm
from app.models import User, Search
from app.custom import require_role
from flask import render_template, redirect, url_for, request, jsonify
@@ -9,11 +10,19 @@ from flask_login import current_user, login_required
def dashboard():
return render_template('/dashboard/dashboard.html')
@app.route('/dashboard/profile_settings')
@app.route('/dashboard/profile_settings', methods=['GET'])
@login_required
def profile_settings():
return render_template('/dashboard/profile_settings.html')
form = ProfileSettingsForm()
return render_template('/dashboard/profile_settings.html', form=form)
@app.route('/dashboard/profile_settings/submit', methods=['POST'])
@login_required
def profile_settings_submit():
form = ProfileSettingsForm()
if form.validate_on_submit():
return jsonify(data={'message' : 'hello {}'.format(form.show_email.data)})
return '$'
@app.route('/dashboard/constants')
@login_required
@require_role(roles=['Admin'])