def RegisterUser(self, request, context):
        key = self.CH.hash(request.username)
        print(f'RegisterUser - Server {SERVER_ID} / Username {request.username} / Username key: {key}')

        node = self.CH.find_successor(key)
        if node.server_id != SERVER_ID:
            print(f'RegisterUser - Redirected to server {node.server_id}')
            try:
                with grpc.insecure_channel(f'{node.host}:{node.port}') as channel:
                    stub = API_pb2_grpc.APIStub(channel)
                    return stub.RegisterUser(request)
            except Exception as e:
                context.set_code(grpc.StatusCode.INVALID_ARGUMENT)
                context.set_details('User Already exists')
                return API_pb2.AuthResponse()
        print(f'RegisterUser - Server {SERVER_ID} executing the action')

        error, data = users.register_user(self.LSMT, request, context)
        if error:
            context.set_code(grpc.StatusCode.INVALID_ARGUMENT)
            context.set_details(data['msg'])
            return API_pb2.AuthResponse()
        else:
            pb_auth_response = API_pb2.AuthResponse()
            pb_auth_response.user.id = data['user']['id']
            pb_auth_response.user.username = data['user']['username']
            pb_auth_response.user.user_type = data['user']['user_type']
            pb_auth_response.user.email = data['user']['email']
            pb_auth_response.user.token = data['token']
            return pb_auth_response
    def Authenticate(self, request, context):
        key = self.CH.hash(request.username)
        print(f'Authenticate - Server {SERVER_ID} / Username {request.username} / Username key: {key}')

        node = self.CH.find_successor(key)
        if node.server_id != SERVER_ID:
            print(f'Authenticate - Redirected to server {node.server_id}')
            try:
                with grpc.insecure_channel(f'{node.host}:{node.port}') as channel:
                    stub = API_pb2_grpc.APIStub(channel)
                    return stub.Authenticate(request)
            except Exception as e:
                context.set_code(grpc.StatusCode.INVALID_ARGUMENT)
                context.set_details('Wrong Credentials')
                return API_pb2.AuthResponse()
        print(f'Authenticate - Server {SERVER_ID} executing the action')

        error, data = authentication.authenticate(self.LSMT, request, context)
        if error:
            context.set_code(grpc.StatusCode.INVALID_ARGUMENT)
            context.set_details(data['msg'])
            return API_pb2.AuthResponse()
        else:
            pb_auth_response = API_pb2.AuthResponse()
            pb_auth_response.user.id = data['user']['id']
            pb_auth_response.user.username = data['user']['username']
            pb_auth_response.user.user_type = data['user']['user_type']
            pb_auth_response.user.email = data['user']['email']

            for match in data['matches']:
                pb_match = pb_auth_response.matches.add()
                pb_match.id = match['id']
                pb_match.recruiter.username = match['recruiter']
                pb_match.employee.username = match['employee']
                pb_match.employee.email = match['employee_email']
                pb_match.recruiter_match = match['recruiter_match']
                pb_match.employee_match = match['employee_match']

            return pb_auth_response