Commit 7c0f22df authored by Cristiano Urban's avatar Cristiano Urban
Browse files

Added e-mail validation on client + fixed error codes numbering on server.

parent 9be5391d
Loading
Loading
Loading
Loading
Loading
+6 −1
Original line number Diff line number Diff line
@@ -5,6 +5,7 @@
# SPDX-License-Identifier: GPL-3.0-or-later
#

import re
import sys

from redis_rpc_client import RedisRPCClient
@@ -47,9 +48,13 @@ class VOSUser(RedisRPCClient):
            except KeyboardInterrupt:
                sys.exit("\nCTRL+C detected. Exiting...")
        while not email:
            # Add email validation here
            try:
                email = input("\nE-mail: ")
                pattern = r"\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Z|a-z]{2,}\b"
                if not re.fullmatch(pattern, email):
                    print("Invalid e-mail address!")
                    email = None
                    continue
            except ValueError:
                print("Input type is not valid!")
            except EOFError:
+2 −2
Original line number Diff line number Diff line
@@ -67,7 +67,7 @@ class UserRPCServer(RedisRPCServer):
                    errorMsg = "User already exists."
                    self.logger.error(errorMsg)
                    response = { "responseType": "ERROR",
                                 "errorCode": 4,
                                 "errorCode": 3,
                                 "errorMsg": errorMsg }
        elif requestBody["requestType"] == "USER_DEL_REQ":
            try:
@@ -113,7 +113,7 @@ class UserRPCServer(RedisRPCServer):
            errorMsg = "Unkown request type."
            self.logger.error(errorMsg)
            response = { "responseType": "ERROR",
                         "errorCode": 6,
                         "errorCode": 4,
                         "errorMsg": errorMsg }
        return response