From 96c5441ac652bb2e7e396381d3fb2e0964ad68da Mon Sep 17 00:00:00 2001 From: Philip Paquette Date: Wed, 11 Sep 2019 17:34:18 -0400 Subject: 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 --- diplomacy/server/request_managers.py | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) (limited to 'diplomacy/server') 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) -- cgit v1.2.3