Ejemplo n.º 1
0
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'))
Ejemplo n.º 2
0
 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))
Ejemplo n.º 3
0
 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))
Ejemplo n.º 4
0
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
Ejemplo n.º 5
0
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"))