def unauthorized_handler(): user_unauthorized.send( user_unauthorized.send(current_app._get_current_object())) url = URLObject(login_url(login_manager.login_view, request.url)) prev_param = make_next_param(url.without_query(), request.referrer or '/') return redirect( url.add_query_param('prev', prev_param).add_query_param('mode', 'action'))
def decorated_view(*args, **kwargs): if not current_user.is_authenticated(): return current_app.login_manager.unauthorized() try: if current_user.is_admin(): return fn(*args, **kwargs) except AttributeError: pass user_unauthorized.send(current_app._get_current_object()) flash("Admin login required for this page","error") return redirect(login_url(current_app.login_manager.login_view,request.url))
def decorated_view(*args, **kwargs): if not current_user.is_authenticated(): return current_app.login_manager.unauthorized() try: if current_user.is_admin(): return fn(*args, **kwargs) except AttributeError: pass user_unauthorized.send(current_app._get_current_object()) flash("Admin login required for this page", "error") return redirect( login_url(current_app.login_manager.login_view, request.url))
def unauthorized(self): ''' This is a slightly patched version of the default flask-login de-auth function. Instead of a 302 redirect we pass some json back for angular to catch ''' user_unauthorized.send(current_app._get_current_object()) if self.unauthorized_callback: return self.unauthorized_callback() ret = jsonify(access_denied=True) ret.status_code = 403 return ret
def unauthorized_handler(): user_unauthorized.send(user_unauthorized.send(current_app._get_current_object())) url = URLObject(login_url(login_manager.login_view, request.url)) prev_param = make_next_param(url.without_query(), request.referrer or "/") return redirect(url.add_query_param("prev", prev_param).add_query_param("mode", "action"))