From b93239d3f853a96f6e1f8ba90cdb47e3b857d439 Mon Sep 17 00:00:00 2001 From: Chris Date: Tue, 5 Dec 2023 08:02:01 -0500 Subject: [PATCH 1/3] MAde change to db.py authentication. --- .../applications/runestone/models/db.py | 1 + .../gluon/packages/dal/pydal/validators.py | 18 +++++++++++++++++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/bases/rsptx/web2py_server/applications/runestone/models/db.py b/bases/rsptx/web2py_server/applications/runestone/models/db.py index 66e467bb..e2b82db9 100644 --- a/bases/rsptx/web2py_server/applications/runestone/models/db.py +++ b/bases/rsptx/web2py_server/applications/runestone/models/db.py @@ -386,6 +386,7 @@ def formatter(self, value): db.auth_user.username.requires = ( HAS_NO_DOTS(), IS_NOT_IN_DB(db, db.auth_user.username), + IS_NOT_EMOJI(db.auth_user.username,f"Username cannot contain emojis") ) db.auth_user.registration_id.requires = IS_NOT_IN_DB(db, db.auth_user.registration_id) db.auth_user.email.requires = ( diff --git a/bases/rsptx/web2py_server/gluon/packages/dal/pydal/validators.py b/bases/rsptx/web2py_server/gluon/packages/dal/pydal/validators.py index 343a98d5..de2c95a7 100644 --- a/bases/rsptx/web2py_server/gluon/packages/dal/pydal/validators.py +++ b/bases/rsptx/web2py_server/gluon/packages/dal/pydal/validators.py @@ -73,6 +73,7 @@ "IS_UPPER", "IS_URL", "IS_JSON", + "IS_NOT_EMOJI", ] @@ -157,6 +158,20 @@ def validator_caller(func, value, record_id=None): raise ValidationError(error) return value +class IS_NOT_EMOJI(Validator): + """ + """ + def __init__(self,expression, error_message="Contains Emojis"): + + self.expression = expression + self.error_message = error_message + def validate(self, value, record_id=None): + print("----------------------Inside Validation Function---------------------------") + emoji_pattern = re.compile(r'[\U0001F600-\U0001F64F\U0001F300-\U0001F5FF\U0001F680-\U0001F6FF\U0001F700-\U0001F77F\U0001F780-\U0001F7FF\U0001F800-\U0001F8FF\U0001F900-\U0001F9FF\U0001FA00-\U0001FA6F\U0001FA70-\U0001FAFF]') + + if emoji_pattern.search(value): + raise ValidationError(self.translator(self.error_message)) + return value class IS_MATCH(Validator): """ @@ -202,6 +217,7 @@ def __init__( extract=False, is_unicode=False, ): + print("----------------------Init Match function---------------------") if strict or not search: if not expression.startswith("^"): @@ -753,7 +769,7 @@ def __init__( allowed_override=[], ignore_common_filters=False, ): - + print("----------------------Inside Init Function---------------------------") if isinstance(field, Table): field = field._id From 36122a219fb05df032123bca0fa110ea4cd50ea2 Mon Sep 17 00:00:00 2001 From: Chris Date: Tue, 5 Dec 2023 09:44:35 -0500 Subject: [PATCH 2/3] Remove debugging print statements. --- .../web2py_server/gluon/packages/dal/pydal/validators.py | 4 ---- 1 file changed, 4 deletions(-) diff --git a/bases/rsptx/web2py_server/gluon/packages/dal/pydal/validators.py b/bases/rsptx/web2py_server/gluon/packages/dal/pydal/validators.py index de2c95a7..f42909b3 100644 --- a/bases/rsptx/web2py_server/gluon/packages/dal/pydal/validators.py +++ b/bases/rsptx/web2py_server/gluon/packages/dal/pydal/validators.py @@ -166,7 +166,6 @@ def __init__(self,expression, error_message="Contains Emojis"): self.expression = expression self.error_message = error_message def validate(self, value, record_id=None): - print("----------------------Inside Validation Function---------------------------") emoji_pattern = re.compile(r'[\U0001F600-\U0001F64F\U0001F300-\U0001F5FF\U0001F680-\U0001F6FF\U0001F700-\U0001F77F\U0001F780-\U0001F7FF\U0001F800-\U0001F8FF\U0001F900-\U0001F9FF\U0001FA00-\U0001FA6F\U0001FA70-\U0001FAFF]') if emoji_pattern.search(value): @@ -217,8 +216,6 @@ def __init__( extract=False, is_unicode=False, ): - print("----------------------Init Match function---------------------") - if strict or not search: if not expression.startswith("^"): expression = "^(%s)" % expression @@ -769,7 +766,6 @@ def __init__( allowed_override=[], ignore_common_filters=False, ): - print("----------------------Inside Init Function---------------------------") if isinstance(field, Table): field = field._id From f718f3730ff8b09a6e1d5f59fbb09735484499fb Mon Sep 17 00:00:00 2001 From: Chris Date: Wed, 6 Dec 2023 18:05:55 -0500 Subject: [PATCH 3/3] Undid formatting changes that weren't necessary. --- .../rsptx/web2py_server/gluon/packages/dal/pydal/validators.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/bases/rsptx/web2py_server/gluon/packages/dal/pydal/validators.py b/bases/rsptx/web2py_server/gluon/packages/dal/pydal/validators.py index f42909b3..6d0c9b83 100644 --- a/bases/rsptx/web2py_server/gluon/packages/dal/pydal/validators.py +++ b/bases/rsptx/web2py_server/gluon/packages/dal/pydal/validators.py @@ -216,6 +216,7 @@ def __init__( extract=False, is_unicode=False, ): + if strict or not search: if not expression.startswith("^"): expression = "^(%s)" % expression @@ -766,6 +767,7 @@ def __init__( allowed_override=[], ignore_common_filters=False, ): + if isinstance(field, Table): field = field._id