summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJesusaves <cpntb1@ymail.com>2022-07-28 20:37:55 -0300
committerJesusaves <cpntb1@ymail.com>2022-07-28 20:37:55 -0300
commit5333221ff7b4197cf1aca20d74bb1cc04e686aab (patch)
tree85136f7ea17105071ac01dc1f01d10ce88acc4f6
parent1dbbecb50b78cdd8bbd4b71c74beb36abde3d6c0 (diff)
downloadserver-5333221ff7b4197cf1aca20d74bb1cc04e686aab.tar.gz
server-5333221ff7b4197cf1aca20d74bb1cc04e686aab.tar.bz2
server-5333221ff7b4197cf1aca20d74bb1cc04e686aab.tar.xz
server-5333221ff7b4197cf1aca20d74bb1cc04e686aab.zip
"Mail" can now be blank, it'll then use MyUID.
If a valid email is provided in a registration but MyUID is repeated, it'll take over the account instead.
-rw-r--r--player.py14
-rw-r--r--sql.py15
2 files changed, 28 insertions, 1 deletions
diff --git a/player.py b/player.py
index d035a72..49d5a8a 100644
--- a/player.py
+++ b/player.py
@@ -816,9 +816,14 @@ def register(args, token):
y=json.loads(args)
tmp=y["email"]
mail=str(tmp)
+ tmp=y["MyUID"]
+ leni=len(tmp)
+ MyUID=str(y["MyUID"])
# Check if email is valid with above regex
if not re.search(regex,mail):
- raise Exception("Not a valid email")
+ if leni != 32 or mail != "":
+ raise Exception("Not a valid email")
+ mail="_%s@spheres.tmw2.org" % (MyUID)
except:
return ERR_BAD
@@ -832,6 +837,13 @@ def register(args, token):
stdout("WARNING: Tried to register email \"%s\" (belongs to account %s)" % (mail, check))
return ERR_BAD
+ # If email is an UID mail, clobber it
+ check=sql.query_email("_%s@spheres.tmw2.org" % (MyUID))
+ if (check != ""):
+ passwd=clobber_email(check, "_%s@spheres.tmw2.org" % (MyUID), mail)
+ stdout("INFO: Set a new email for \"%s\" (%s)" % (check, mail))
+ return compress({"userid": userid, "password": passwd})
+
stdout("Now registering account")
# Register it
data=sql.add_player(mail)
diff --git a/sql.py b/sql.py
index 21aa065..0f79033 100644
--- a/sql.py
+++ b/sql.py
@@ -247,6 +247,21 @@ def query_email(xmail):
return c
+def clobber_email(userid, oldmail, newmail):
+ w = db.cursor(dictionary=True)
+ w.execute("SELECT `userpw` FROM `login` WHERE `userid`='%s' AND `email`='%s'" % (userid, oldmail))
+ r = w.fetchall()
+ c = ""
+ for it in r:
+ c+=str(it)
+ w.close()
+ w = db.cursor()
+ w.execute("UPDATE `login` SET `email` = '%s' WHERE `userid`='%s' AND `email`='%s'" % (newmail, userid, oldmail))
+ w.close()
+
+ return c
+
+
def add_player(xmail):
# TODO: Generate password using the whole alphabet.
# The original string have 32 letters and we're using only 12