fix: regex change for username
This commit is contained in:
@@ -18,6 +18,8 @@ class CustomUser(User):
|
||||
else:
|
||||
underscore_condition = ''
|
||||
|
||||
regex = re.compile('[@!#$%^&*()<>?/\|}{~:-]')
|
||||
|
||||
if self.is_new():
|
||||
if not self.username:
|
||||
self.username = self.get_username_from_first_name()
|
||||
@@ -25,7 +27,7 @@ class CustomUser(User):
|
||||
if self.username.find(" "):
|
||||
self.username.replace(" ", "")
|
||||
|
||||
if not re.match("^[A-Za-z0-9_]*$", self.username) or underscore_condition:
|
||||
if regex.search(self.username) or underscore_condition:
|
||||
self.username = self.remove_illegal_characters()
|
||||
|
||||
if len(self.username) < 4:
|
||||
@@ -38,7 +40,7 @@ class CustomUser(User):
|
||||
if not self.username:
|
||||
frappe.throw(_("Username already exists."))
|
||||
|
||||
if not re.match("^[A-Za-z0-9_]*$", self.username):
|
||||
if regex.search(self.username):
|
||||
frappe.throw(_("Username can only contain alphabets, numbers and underscore."))
|
||||
|
||||
if underscore_condition:
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import frappe
|
||||
from community.page_renderers import get_profile_url_prefix
|
||||
from urllib.parse import urlencode
|
||||
|
||||
def get_context(context):
|
||||
context.no_cache = 1
|
||||
@@ -9,14 +10,15 @@ def get_context(context):
|
||||
except KeyError:
|
||||
username = frappe.db.get_value("User", frappe.session.user, ["username"])
|
||||
if username:
|
||||
frappe.local.flags.redirect_location = get_profile_url_prefix() + username
|
||||
print(username)
|
||||
frappe.local.flags.redirect_location = get_profile_url_prefix() + urlencode({"username": username})
|
||||
raise frappe.Redirect
|
||||
try:
|
||||
context.member = frappe.get_doc("User", {"username": username})
|
||||
except:
|
||||
context.template = "www/404.html"
|
||||
return
|
||||
|
||||
print(context.member)
|
||||
context.profile_tabs = get_profile_tabs(context.member)
|
||||
|
||||
def get_profile_tabs(user):
|
||||
|
||||
Reference in New Issue
Block a user