diff --git a/SE_API/UserRoutes.py b/SE_API/UserRoutes.py index e487f2a..efad1bc 100644 --- a/SE_API/UserRoutes.py +++ b/SE_API/UserRoutes.py @@ -70,6 +70,57 @@ def getUserByToken(token): return bad_request("No User Found") +@user_routes.route('/api/users/updateUser/', methods=["GET"]) +@auto.doc() +def updateUser(token): + """ + >This Call will update user details +
+ Route Parameters
+ - seToken: 'seToken' +
+
+ Payload
+ - JSON Object, Example:
+ {
+ 'name': 'Campus name',
+ 'isLecturer': '@campus.ac.com',
+ }
+
+ Response +
+ 200 - User updated +
+ 400 - Bad Request + """ + + if not request.data: + return bad_request() + + try: + payload = json.loads(request.data) + except Exception as e: + return bad_request(e) + + user = get_user_by_token(token) + if user is None: + return bad_request("Not a user!") + + try: + user.name = payload['user'] + except Exception: + pass + + try: + user.isLecturer = payload['isLecturer'] + except Exception: + pass + + + return ok("User updated") + + + @user_routes.route('/api/users/help') def documentation(): return auto.html() \ No newline at end of file