when not logged in, redirect to sign-in

parts of the initial setup/login stages were throwing 500s if user
not already in process (ie: user directly navigated to url):
* /resend-email-verification
* /text-not-received
* /send-new-code
* verify
This commit is contained in:
Leo Hemsted
2016-06-17 11:36:30 +01:00
parent 7be111d260
commit 539950d772
6 changed files with 44 additions and 16 deletions

View File

@@ -1,9 +1,9 @@
import re
import csv
from io import BytesIO, StringIO
from io import StringIO
from os import path
from functools import wraps
from flask import (abort, session, request, url_for)
from flask import (abort, session, request, redirect, url_for)
import pyexcel
import pyexcel.ext.io
import pyexcel.ext.xls
@@ -51,6 +51,16 @@ def user_has_permissions(*permissions, admin_override=False, any_=False):
return wrap
def redirect_to_sign_in(f):
@wraps(f)
def wrapped(*args, **kwargs):
if 'user_details' not in session:
return redirect(url_for('main.sign_in'))
else:
return f(*args, **kwargs)
return wrapped
def get_errors_for_csv(recipients, template_type):
errors = []