Mercurial > piecrust2
changeset 608:8e1b38632702
admin: Show the install page if no secret key is available.
author | Ludovic Chabant <ludovic@chabant.com> |
---|---|
date | Wed, 27 Jan 2016 23:39:00 -0800 |
parents | c67dcc0fa80f |
children | 978d8bca9fb3 |
files | foodtruck/web.py |
diffstat | 1 files changed, 17 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/foodtruck/web.py Wed Jan 27 22:47:24 2016 -0800 +++ b/foodtruck/web.py Wed Jan 27 23:39:00 2016 -0800 @@ -91,6 +91,15 @@ logging.exception(ex) +_missing_secret_key = False + +if not app.secret_key: + # If there's no secret key, create a temp one but mark the app as not + # correctly installed so it shows the installation information page. + app.secret_key = 'temp-key' + _missing_secret_key = True + + from flask.ext.login import LoginManager, UserMixin @@ -113,6 +122,14 @@ login_manager.login_view = 'login' login_manager.user_loader(load_user) +if _missing_secret_key: + def _handler(): + raise FoodTruckConfigNotFoundError() + + logger.debug("No secret key found, disabling website.") + login_manager.unauthorized_handler(_handler) + login_manager.login_view = None + try: from flask.ext.bcrypt import Bcrypt