comparison piecrust/admin/blueprint.py @ 783:a9f4a6e60b0b

admin: Fix various crashes caused by incorrect Blueprint setup.
author Ludovic Chabant <ludovic@chabant.com>
date Sun, 28 Aug 2016 20:48:05 -0700
parents 5e91bc0e3b4d
children 82509bce94ca
comparison
equal deleted inserted replaced
782:df58592b40f8 783:a9f4a6e60b0b
28 return User(admin_id, admin_pwd) 28 return User(admin_id, admin_pwd)
29 return None 29 return None
30 30
31 31
32 login_manager = LoginManager() 32 login_manager = LoginManager()
33 login_manager.login_view = 'login' 33 login_manager.login_view = 'FoodTruck.login'
34 login_manager.user_loader(load_user) 34 login_manager.user_loader(load_user)
35 35
36 36
37 def record_login_manager(state): 37 def record_login_manager(state):
38 if state.app.secret_key == 'temp-key': 38 if state.app.secret_key == 'temp-key':
40 raise FoodTruckConfigNotFoundError() 40 raise FoodTruckConfigNotFoundError()
41 41
42 logger.debug("No secret key found, disabling website login.") 42 logger.debug("No secret key found, disabling website login.")
43 login_manager.unauthorized_handler(_handler) 43 login_manager.unauthorized_handler(_handler)
44 login_manager.login_view = None 44 login_manager.login_view = None
45
46 login_manager.init_app(state.app)
45 47
46 48
47 # Setup Bcrypt. 49 # Setup Bcrypt.
48 from .bcryptfallback import Bcrypt 50 from .bcryptfallback import Bcrypt
49 bcrypt_ext = Bcrypt() 51 bcrypt_ext = Bcrypt()
53 if (getattr(Bcrypt, 'is_fallback_bcrypt', None) is True and 55 if (getattr(Bcrypt, 'is_fallback_bcrypt', None) is True and
54 not state.app.config.get('FOODTRUCK_CMDLINE_MODE', False)): 56 not state.app.config.get('FOODTRUCK_CMDLINE_MODE', False)):
55 raise Exception( 57 raise Exception(
56 "You're running FoodTruck outside of `chef`, and will need to " 58 "You're running FoodTruck outside of `chef`, and will need to "
57 "install Flask-Bcrypt to get more proper security.") 59 "install Flask-Bcrypt to get more proper security.")
60
61 bcrypt_ext.init_app(state.app)
62 state.app.bcrypt = bcrypt_ext
58 63
59 64
60 # Create the FoodTruck blueprint. 65 # Create the FoodTruck blueprint.
61 foodtruck_bp = Blueprint( 66 foodtruck_bp = Blueprint(
62 'FoodTruck', __name__, 67 'FoodTruck', __name__,