From 50b17b36266391da8cec1a66eca46153cf132176 Mon Sep 17 00:00:00 2001 From: Greg Taylor Date: Tue, 3 Apr 2007 15:17:46 +0000 Subject: [PATCH] Changing the user login command to use the player's email address instead of username. Also Require quotes around the username with the character creation command regardless of whether it's two words or one. --- commands_unloggedin.py | 37 +++++++++++++++++++++++++------------ evennia.sql | Bin 65536 -> 65536 bytes functions_db.py | 6 ++++++ session.py | 6 +++--- 4 files changed, 34 insertions(+), 15 deletions(-) diff --git a/commands_unloggedin.py b/commands_unloggedin.py index c789b9708..a3fecbecb 100644 --- a/commands_unloggedin.py +++ b/commands_unloggedin.py @@ -10,25 +10,32 @@ def cmd_connect(cdat): This is the connect command at the connection screen. Fairly simple, uses the Django database API and User model to make it extremely simple. """ + session = cdat['session'] - uname = cdat['uinput']['splitted'][1] + + if len(cdat['uinput']['splitted']) != 3: + session.msg("Missing arguments!") + return + + uemail = cdat['uinput']['splitted'][1] password = cdat['uinput']['splitted'][2] + + # Match an email address to an account. + email_matches = functions_db.get_dbref_from_email(uemail) - account = User.objects.filter(username__iexact=uname) - - autherror = "Invalid username or password!" + autherror = "Specified email does not match any accounts!" # No username match - if account.count() == 0: + if email_matches.count() == 0: session.msg(autherror) return - # We have at least one result, so we can check hte password. - user = account[0] + # We have at least one result, so we can check the password. + user = email_matches[0] if not user.check_password(password): session.msg(autherror) else: - user = account[0] + user = email_matches[0] uname = user.username session.login(user) @@ -38,15 +45,21 @@ def cmd_create(cdat): """ session = cdat['session'] server = session.server - uname = cdat['uinput']['splitted'][1] - email = cdat['uinput']['splitted'][2] - password = cdat['uinput']['splitted'][3] - + quote_split = ' '.join(cdat['uinput']['splitted']).split("\"") + uname = quote_split[1] + lastarg_split = quote_split[2].split() + email = lastarg_split[0] + password = lastarg_split[1] + # Search for a user object with the specified username. account = User.objects.filter(username=uname) + # Match an email address to an account. + email_matches = functions_db.get_dbref_from_email(email) if not account.count() == 0: session.msg("There is already a player with that name!") + elif not email_matches.count() == 0: + session.msg("There is already a player with that email address!") elif len(password) < 3: session.msg("Your password must be 3 characters or longer.") else: diff --git a/evennia.sql b/evennia.sql index e660cc1513fedb85bdb7d05e3efcbd99a6f17d2e..e67d8c94a253a982c11152a2eec9ebab8b0f48c1 100755 GIT binary patch delta 1206 zcma)*O-vI(6vyYILf5b&LRlL{Smnz^>dfx!$22i&&}d@RiyoB3WV_uJ6DWy*#)Gsa zAsW4ido?7)3m!|;au@D+@St8b#zc?8!FX`CMYezklgWO}|3CA7@6DS+Ayz2FUL1i7 zrK8_k4>bc9z)jqQ=g<@Q0BizxzIZiXJgBq)RhIS1xD-Ese#)DiVm%K>J@4+6^Jr}1 z{yBHd8=suWrM&F)ic5O;X+~>cTCUF2(g9; z8zOoSrD>w42~Tlmacb3-{J*4`&K8iAWu=aEJY>>Cq~kRJZg7M4y2Qx1F4r?+cz%ZX zOf$utWf99J4)?fAY+XEe0gyD~DZ{oX)oV&VVr!6Q5_0u03@Ku^1$PcmhjzJ zkBElZL=)%1v&6Iog2S_vIJ)LhW)Z`2O+8BtJ8K)d;W8`RSPqglc$yJG!->xKDAKkR z+C|Dua5aWZ)P`r_cl;KvmWsFGO}GY9$#`6nfFyUT z$t&L2gL}E*>({Pb9KLb!fqHC8UrgSysDiQFlRv48oQZOC&LX rtajZHml5sLPAf9_o4nkZe6+*PoclUtup`Y%v$H0n0fQhT2LqD=Q!rB#(@Lg`Oy8Jgn4Ouk zm?tvdVEoN^gOP)A4Pygi$i&8b^=cx#3?M@p5r!JE0Zld6H89jQFb0`wBpq##3$$DX zY&iobgDAvuGr#=2RAi-E;!v}Y)Ucr|0tO|>JS{P>T3=2^gkn=HicP_aMKKIE!J^h= za`IO7$xPcKCR=RPpWFpx-`uJ(dDB+a$>+DJF{$!Sj@jlrIeMGg \n\r - create \n\r""" + connect \n\r + create \"\" \n\r""" buffer += '-'*50 session.msg(buffer)