- Timestamp:
- May 7, 2023, 5:05:29 PM (19 months ago)
- Location:
- binary-improvements2/WebServer/src/WebAPI/APIs/Permissions
- Files:
-
- 1 added
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
binary-improvements2/WebServer/src/WebAPI/APIs/Permissions/RegisterUser.cs
r432 r433 79 79 return; 80 80 } 81 82 if (AdminWebUsers.Instance.GetUsers ().TryGetValue (username, out AdminWebUsers.WebUser existingMapping)) { 83 // Username already exists 84 85 if (!PlatformUserIdentifierAbs.Equals (existingMapping.PlatformUser, regData.PlatformUserId) || 86 !PlatformUserIdentifierAbs.Equals (existingMapping.CrossPlatformUser, regData.CrossPlatformUserId)) { 87 // Username already in use by another player 88 SendErrorResult (_context, HttpStatusCode.Unauthorized, _jsonInputData, "DUPLICATE_USERNAME"); 89 return; 90 } 91 92 // Username used by the same player, allow overwriting his existing login 93 } 81 94 82 // TODO: Check if username is already used by someone else! 83 // TODO: Remove existing username if player already had one! 95 // Log info 96 string crossplatformidString = regData.CrossPlatformUserId == null ? "" : $", crossplatform ID {regData.CrossPlatformUserId.CombinedString}"; 97 global::Log.Out ($"[Web] User registered: Username '{username}' for platform ID {regData.PlatformUserId.CombinedString}{crossplatformidString}"); 84 98 99 if (AdminWebUsers.Instance.HasUser (regData.PlatformUserId, regData.CrossPlatformUserId, out AdminWebUsers.WebUser existingUser)) { 100 // Remove existing username of player, only allowing one user per player 101 102 global::Log.Out ($"[Web] Re-registration, replacing existing username '{existingUser.Name}'"); 103 AdminWebUsers.Instance.RemoveUser (existingUser.Name); 104 } 105 106 // Add new user 85 107 AdminWebUsers.Instance.AddUser (username, password, regData.PlatformUserId, regData.CrossPlatformUserId); 86 108 109 // Login with new user and return response 87 110 string remoteEndpointString = _context.Request.RemoteEndPoint!.ToString (); 88 111 SessionHandler.HandleUserIdLogin (ParentWeb.ConnectionHandler, _context, remoteEndpointString, SessionHandler.userPassLoginName, … … 93 116 _context.Response.ContentEncoding = Encoding.UTF8; 94 117 _context.Response.ContentLength64 = 0; 95 // _context.Response.OutputStream.Write (jsonData.Array!, 0, jsonData.Count);96 118 } 97 119
Note:
See TracChangeset
for help on using the changeset viewer.