Example #1
0
 def is_accessible(self):
     if current_app.config['DEBUG']:
         g.user = User(FAKE_USER)
         return True
     else:
         g.user = get_current_user()
         if not g.user:
             return False
         return check_rbac([RBACAction.KAE_ADMIN])
Example #2
0
        def _(*args, **kwargs):
            if current_app.config['DEBUG']:
                g.user = User(FAKE_USER)
            else:
                g.user = get_current_user(require_token, scopes_required)

            if not g.user:
                # TODO: change the message
                abort(403, "please provide valid token or user/password")
            return func(*args, **kwargs)
Example #3
0
def login():
    user = get_current_user()
    next_url = request.args.get('next')
    if user:
        if next_url:
            return redirect(next_url)
        return jsonify(user.to_dict())
    # always generate https redirect url
    redirect_uri = url_for('user.authorized', _external=True, _scheme='https')
    session['next'] = next_url
    return oauth_client.authorize_redirect(redirect_uri)
Example #4
0
    def is_accessible(self):
        if current_app.config['DEBUG']:
            g.user = User(**FAKE_USER)
        else:
            g.user = get_current_user()
        if not g.user:
            abort(403, "please login")
        elif g.user.privileged != 1:
            abort(403, 'dude you are not administrator')

        return True
Example #5
0
        def _(*args, **kwargs):
            if current_app.config['DEBUG']:
                g.user = User(**FAKE_USER)
            else:
                g.user = get_current_user()
            if not g.user:
                # TODO: change the message
                abort(403, '{}?next={}'.format(url_for('user.login'),
                                               request.url))
            elif privileged and g.user.privileged != 1:
                abort(403, 'dude you are not administrator')

            return func(*args, **kwargs)