minor user work
This commit is contained in:
1 parent
a66d2133a0
commit
789543f342
1 file changed
+15
-3
+15
-3
@@ -35,8 +35,15 @@ def get_current_user():
|
||||
return jsonify(current_user.to_dict())
|
||||
return "Unauthd", 403
|
||||
|
||||
@auth.route("/users/all")
|
||||
@login_required
|
||||
def get_all_users():
|
||||
if current_user.is_authenticated and current_user.is_admin:
|
||||
users = User.query.all()
|
||||
return jsonify([user.to_dict() for user in users])
|
||||
return "Unathd", 403
|
||||
|
||||
@auth.route("/user", methods=["POST"])
|
||||
@auth.route("/users", methods=["POST"])
|
||||
def create_user():
|
||||
username = request.get_json()["username"]
|
||||
password = request.get_json()["password"]
|
||||
@@ -61,8 +68,13 @@ def update_user(user_id):
|
||||
|
||||
@auth.route("/user/<user_id>", methods=["DELETE"])
|
||||
@login_required
|
||||
def delete_user():
|
||||
return
|
||||
def delete_user(user_id):
|
||||
if (current_user.is_authenticated and current_user.is_admin):
|
||||
user = User.query.get_or_404(user_id)
|
||||
db.session.delete(user)
|
||||
db.session.commit()
|
||||
|
||||
return "", 400
|
||||
|
||||
|
||||
@auth.route("/user/<user_id>")
|
||||
|
||||
Reference in new issue
Block a user