diff --git a/api/chalicelib/core/authorizers.py b/api/chalicelib/core/authorizers.py index c32f08208..a474fcb8d 100644 --- a/api/chalicelib/core/authorizers.py +++ b/api/chalicelib/core/authorizers.py @@ -15,7 +15,7 @@ def jwt_authorizer(token): token[1], config("jwt_secret"), algorithms=config("jwt_algorithm"), - audience=[f"plugin:{helper.get_stage_name()}", f"front:{helper.get_stage_name()}"] + audience=[ f"front:{helper.get_stage_name()}"] ) except jwt.ExpiredSignatureError: print("! JWT Expired signature") diff --git a/api/chalicelib/core/signup.py b/api/chalicelib/core/signup.py index 23c2c8744..9106084ad 100644 --- a/api/chalicelib/core/signup.py +++ b/api/chalicelib/core/signup.py @@ -21,7 +21,7 @@ def create_step1(data: schemas.UserSignupSchema): password = data.password print("Verifying email validity") - if email is None or len(email) < 5 or not helper.is_valid_email(email): + if email is None or len(email) < 5: errors.append("Invalid email address.") else: print("Verifying email existance") diff --git a/api/chalicelib/utils/helper.py b/api/chalicelib/utils/helper.py index 192c309f5..919ac9d9f 100644 --- a/api/chalicelib/utils/helper.py +++ b/api/chalicelib/utils/helper.py @@ -18,40 +18,13 @@ def get_version_number(): def get_stage_name(): - stage = config("STAGE") - return stage[len(local_prefix):] if stage.startswith(local_prefix) else stage - - -def is_production(): - return get_stage_name() == "production" - - -def is_staging(): - return get_stage_name() == "staging" - - -def is_onprem(): - return not is_production() and not is_staging() - - -def is_local(): - return config("STAGE").startswith(local_prefix) + return "OpenReplay" def generate_salt(): return "".join(random.choices(string.hexdigits, k=36)) -def unique_ordered_list(array): - uniq = [] - [uniq.append(x) for x in array if x not in uniq] - return uniq - - -def unique_unordered_list(array): - return list(set(array)) - - def list_to_camel_case(items, flatten=False): for i in range(len(items)): if flatten: @@ -130,12 +103,6 @@ def key_to_snake_case(name, delimiter='_', split_number=False): TRACK_TIME = True -def __sbool_to_bool(value): - if value is None or not isinstance(value, str): - return False - return value.lower() in ["true", "yes", "1"] - - def allow_captcha(): return config("captcha_server", default=None) is not None and config("captcha_key", default=None) is not None \ and len(config("captcha_server")) > 0 and len(config("captcha_key")) > 0 @@ -210,54 +177,11 @@ def values_for_operator(value: Union[str, list], op: schemas.SearchEventOperator return value -def is_valid_email(email): - return re.match(r"[^@]+@[^@]+\.[^@]+", email) is not None - - -def is_valid_http_url(url): - regex = re.compile( - r'^(?:http|ftp)s?://' # http:// or https:// - r'(?:(?:[A-Z0-9](?:[A-Z0-9-]{0,61}[A-Z0-9])?\.)+(?:[A-Z]{2,6}\.?|[A-Z0-9-]{2,}\.?)|' # domain... - r'localhost|' # localhost... - r'\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})' # ...or ip - r'(?::\d+)?' # optional port - r'(?:/?|[/?]\S+)$', re.IGNORECASE) - - return re.match(regex, url) is not None - - -def is_valid_url(url): - regex = re.compile( - # r'^(?:http|ftp)s?://' # http:// or https:// - r'(?:(?:[A-Z0-9](?:[A-Z0-9-]{0,61}[A-Z0-9])?\.)+(?:[A-Z]{2,6}\.?|[A-Z0-9-]{2,}\.?)|' # domain... - r'localhost|' # localhost... - r'\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})' # ...or ip - r'(?::\d+)?' # optional port - r'(?:/?|[/?]\S+)$', re.IGNORECASE) - - return re.match(regex, url) is not None - - -def is_alphabet_space(word): - r = re.compile("^[a-zA-Z ]*$") - return r.match(word) is not None - - -def is_alphabet_latin_space(word): - r = re.compile("^[a-zA-Z\u00C0-\u00D6\u00D8-\u00f6\u00f8-\u00ff\s ]*$") - return r.match(word) is not None - - def is_alphabet_space_dash(word): r = re.compile("^[a-zA-Z -]*$") return r.match(word) is not None -def is_alphanumeric_space(word): - r = re.compile("^[a-zA-Z0-9._\- ]*$") - return r.match(word) is not None - - def merge_lists_by_key(l1, l2, key): merged = {} for item in l1 + l2: @@ -310,9 +234,6 @@ def explode_widget(data, key=None): return result -TEMP_PATH = "./" if is_local() else "/tmp/" - - def get_issue_title(issue_type): return {'click_rage': "Click Rage", 'dead_click': "Dead Click",