diff options
author | Jesusaves <cpntb1@ymail.com> | 2022-07-28 20:37:55 -0300 |
---|---|---|
committer | Jesusaves <cpntb1@ymail.com> | 2022-07-28 20:37:55 -0300 |
commit | 5333221ff7b4197cf1aca20d74bb1cc04e686aab (patch) | |
tree | 85136f7ea17105071ac01dc1f01d10ce88acc4f6 | |
parent | 1dbbecb50b78cdd8bbd4b71c74beb36abde3d6c0 (diff) | |
download | server-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.py | 14 | ||||
-rw-r--r-- | sql.py | 15 |
2 files changed, 28 insertions, 1 deletions
@@ -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) @@ -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 |