예제 #1
0
파일: auth.py 프로젝트: will133/flask-todo
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'))
예제 #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))
예제 #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))
예제 #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
예제 #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"))