OG and Cookie settings

This commit is contained in:
Vivek Santayana 2021-12-06 21:51:29 +00:00
parent ca1a6efd57
commit e7077cd193
4 changed files with 24 additions and 9 deletions

View File

@ -25,7 +25,9 @@ class User:
value = self._id,
max_age = timedelta(days=14) if self.remember else 'Session',
path = '/',
expires = datetime.utcnow() + timedelta(days=14) if self.remember else 'Session'
expires = datetime.utcnow() + timedelta(days=14) if self.remember else 'Session',
domain = '.reftest.vsnt.uk',
secure = True
)
if self.remember:
resp.set_cookie (
@ -33,7 +35,9 @@ class User:
value = 'True',
max_age = timedelta(days=14),
path = '/',
expires = datetime.utcnow() + timedelta(days=14)
expires = datetime.utcnow() + timedelta(days=14),
domain = '.reftest.vsnt.uk',
secure = True
)
def register(self):
@ -80,21 +84,27 @@ class User:
value = '',
max_age = timedelta(days=-1),
path = '/',
expires= datetime.utcnow() + timedelta(days=-1)
expires= datetime.utcnow() + timedelta(days=-1),
domain = '.reftest.vsnt.uk',
secure = True
)
resp.set_cookie (
key = 'cookie_consent',
value = 'True',
max_age = 'Session',
path = '/',
expires = 'Session'
expires = 'Session',
domain = '.reftest.vsnt.uk',
secure = True
)
resp.set_cookie (
key = 'remember',
value = 'True',
max_age = timedelta(days=-1),
path = '/',
expires = datetime.utcnow() + timedelta(days=-1)
expires = datetime.utcnow() + timedelta(days=-1),
domain = '.reftest.vsnt.uk',
secure = True
)
flash('You have been logged out. All cookies pertaining to your account have been deleted. Have a nice day.', 'alert')
return resp

View File

@ -13,6 +13,8 @@ def _cookies():
value = 'True',
max_age = timedelta(days=14) if request.cookies.get('remember') == 'True' else 'Session',
path = '/',
expires = datetime.utcnow() + timedelta(days=14) if request.cookies.get('remember') else 'Session'
expires = datetime.utcnow() + timedelta(days=14) if request.cookies.get('remember') else 'Session',
domain = '.reftest.vsnt.uk',
secure = True
)
return resp

View File

@ -8,6 +8,7 @@ from pymongo import MongoClient
from pymongo.errors import ConnectionFailure
from flask_wtf.csrf import CSRFProtect, CSRFError
from flask_mail import Mail
from werkzeug.middleware.proxy_fix import ProxyFix
from common.security import check_keyfile_exists, generate_keyfile
import config
@ -70,6 +71,8 @@ def create_app():
Bootstrap(app)
csrf = CSRFProtect(app)
app.wsgi_app = ProxyFix(app.wsgi_app, x_proto=1, x_host=1)
return app
app = create_app()

View File

@ -2,12 +2,12 @@
<meta property="og:locale" content="en_UK" />
<meta property="og:type" content="website" />
<meta property="og:description" content="A web app for taking the Scottish Korfball Association Refereeing Theory Exam on-line." />
<meta property="og:url" content="{{ url_for(request.endpoint, **request.view_args, _external = True) }}" />
<meta property="og:url" content="{{ url_for(request.endpoint, _external = True, **request.view_args) }}" />
<meta property="og:site_name" content="Scottish Korfball Association Referee Theory Exam" />
<meta property="og:image" content="{{ url_for('static', filename='favicon.png', _external = True) }}" />
<meta property="og:image:alt" content="Logo of the SKA Refereeing Exam App" />
<meta property="og:image:width" content="1024" />
<meta property="og:image:height" content="1024" />
<meta property="og:image:width" content="512" />
<meta property="og:image:height" content="512" />
<meta name="twitter:card" content="summary" />
<meta name="twitter:description" content="A web app for taking the Scottish Korfball Association Refereeing Theory Exam on-line." />
<meta name="twitter:image" content="{{ url_for('static', filename='favicon.png', _external = True) }}" />