aboutsummaryrefslogtreecommitdiff
path: root/diplomacy/server/request_managers.py
diff options
context:
space:
mode:
authorPhilip Paquette <pcpaquette@gmail.com>2019-09-11 17:34:18 -0400
committerPhilip Paquette <pcpaquette@gmail.com>2019-09-14 18:18:53 -0400
commit96c5441ac652bb2e7e396381d3fb2e0964ad68da (patch)
tree29a582fd80553b47ea25d25908f2b624ae5c54c8 /diplomacy/server/request_managers.py
parent57c9c33ae756cc17af223f6bc671191684ee9c9b (diff)
channel.authenticate() - Deprecated argument 'create_user'
- User is now created by default if it doesn't exist on the server - Unless the server prevents new registrations
Diffstat (limited to 'diplomacy/server/request_managers.py')
-rw-r--r--diplomacy/server/request_managers.py21
1 files changed, 12 insertions, 9 deletions
diff --git a/diplomacy/server/request_managers.py b/diplomacy/server/request_managers.py
index 073a7ef..9e61044 100644
--- a/diplomacy/server/request_managers.py
+++ b/diplomacy/server/request_managers.py
@@ -1068,20 +1068,23 @@ def on_sign_in(server, request, connection_handler):
:type request: diplomacy.communication.requests.SignIn
"""
# No channel/game request verification to do.
- username, password, create_user = request.username, request.password, request.create_user
- if create_user:
- # Register.
- if not username:
- raise exceptions.UserException()
- if not password:
- raise exceptions.PasswordException()
+ username, password = request.username, request.password
+
+ if not username:
+ raise exceptions.UserException()
+ if not password:
+ raise exceptions.PasswordException()
+
+ # New user
+ if not server.users.has_username(username):
if not server.allow_registrations:
raise exceptions.ServerRegistrationException()
- if server.users.has_username(username):
- raise exceptions.UserException()
server.users.add_user(username, hash_password(password))
+
+ # Existing user
elif not server.users.has_user(username, password):
raise exceptions.UserException()
+
token = server.users.connect_user(username, connection_handler)
server.save_data()
return responses.DataToken(data=token, request_id=request.request_id)