Commit c19b4db8 authored by Alex Kakiris's avatar Alex Kakiris
Browse files

Fix response messages for register operations

parent 5eab19d4
Loading
Loading
Loading
Loading
Loading
+4 −4
Original line number Original line Diff line number Diff line
@@ -52,11 +52,11 @@ class RegisterOperations:
            exist_user = mycol.find_one({"username": username})
            exist_user = mycol.find_one({"username": username})


            if exist_user is None:
            if exist_user is None:
                return jsonify("Not exister user with this credentials"), 400
                return jsonify("No user with these credentials"), 400


            stored_password = exist_user["password"]
            stored_password = exist_user["password"]
            if not bcrypt.checkpw(password.encode('utf-8'), stored_password):
            if not bcrypt.checkpw(password.encode('utf-8'), stored_password):
                    return jsonify("Not exister user with this credentials"), 400
                    return jsonify("No user with these credentials"), 400
            
            
            access_token = create_access_token(identity=(username + " " + exist_user["role"]))
            access_token = create_access_token(identity=(username + " " + exist_user["role"]))
            url = f"http://{self.config['ca_factory']['url']}:{self.config['ca_factory']['port']}/v1/secret/data/ca"
            url = f"http://{self.config['ca_factory']['url']}:{self.config['ca_factory']['port']}/v1/secret/data/ca"
@@ -78,11 +78,11 @@ class RegisterOperations:
            exist_user = mycol.find_one({"username": username})
            exist_user = mycol.find_one({"username": username})


            if exist_user is None:
            if exist_user is None:
                return jsonify("Not exister user with this username"), 400
                return jsonify("No user with these credentials"), 400


            stored_password = exist_user["password"]
            stored_password = exist_user["password"]
            if not bcrypt.checkpw(password.encode('utf-8'), stored_password):
            if not bcrypt.checkpw(password.encode('utf-8'), stored_password):
                    return jsonify("Not exister user with this password"), 400
                    return jsonify("No user with these credentials"), 400
            
            
            mycol.delete_one({"username": username})
            mycol.delete_one({"username": username})
            return jsonify(message="User removed successfully"), 204
            return jsonify(message="User removed successfully"), 204