def register_extensions(app): """Register Flask extensions.""" bcrypt.init_app(app) db.init_app(app) csrf_protect.init_app(app) login_manager.session_protection = 'strong' @login_manager.user_loader def load_user(user_id): current_app.logger.info(user_id) app.logger.info('============ @app.user_loader ============') return UserModel.query.get(user_id) @login_manager.unauthorized_handler def unauthorized(): # TODO log current_app.logger.info('============ @login_manager.unauthorized_handler ============') return BaseAPI.ApiResource.json(code=Code.unlogin) login_manager.init_app(app) migrate.init_app(app, db) mail.init_app(app) permission.init_app(app) return app
def register_extensions(app): """Register Flask extensions.""" bcrypt.init_app(app) db.init_app(app) csrf_protect.init_app(app) login_manager.session_protection = 'strong' @login_manager.user_loader def load_user(user_id): current_app.logger.info(user_id) app.logger.info('============ @app.user_loader ============') return UserModel.query.get(user_id) @login_manager.unauthorized_handler def unauthorized(): # TODO log current_app.logger.info( '============ @login_manager.unauthorized_handler ============') # return Response(ApiResource.render_json(code=Code.space_error)) return BaseAPI.ApiResource.json(code=Code.unlogin) login_manager.init_app(app) migrate.init_app(app, db) mail.init_app(app) permission.init_app(app) return app
def register_extensions(app): """Register Flask extensions.""" bcrypt.init_app(app) db.init_app(app) csrf_protect.init_app(app) login_manager.session_protection = 'strong' login_manager.anonymous_user = AnonymousUser @login_manager.user_loader def load_user(user_id): current_app.logger.info(user_id) return UserModel.query.get(user_id) @login_manager.unauthorized_handler def unauthorized(): # TODO log return BaseAPI.ApiResource.json(code=Code.unlogin) login_manager.init_app(app) migrate.init_app(app, db) mail.init_app(app) permission.init_app(app) return app