Example #1
0
def create_root():
    if User.find_by_id(1):
        return jsonify(msg="there is already a root!"), 403
    data = request.get_json()
    data['password'] = User.generate_hash(data['password'])
    user_schmea = UserSchema()
    user = user_schmea.load(data)
    user.role = 'root'
    user.isVerified = True
    user.create()
    return response_with(resp.SUCCESS_201)
Example #2
0
 def decorator(*args, **kwargs):
     current_user = User.find_by_id(get_jwt_identity())
     if ACCESS[current_user.role] >= ACCESS[role]:
         return fn(*args, **kwargs)
     else:
         return jsonify(msg="User needs to be {}!".format(role)), 403