- Timestamp:
- May 17, 2023, 11:05:59 PM (18 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
binary-improvements2/WebServer/src/WebAPI/APIs/Permissions/RegisterUser.cs
r433 r434 9 9 using Webserver.UrlHandlers; 10 10 11 namespace Webserver.WebAPI.APIs {11 namespace Webserver.WebAPI.APIs.Permissions { 12 12 [UsedImplicitly] 13 13 public class RegisterUser : AbsRestApi { … … 27 27 28 28 if (string.IsNullOrEmpty (token)) { 29 SendE rrorResult(_context, HttpStatusCode.BadRequest, null, "NO_TOKEN");29 SendEmptyResponse (_context, HttpStatusCode.BadRequest, null, "NO_TOKEN"); 30 30 return; 31 31 } 32 32 33 33 if (!UserRegistrationTokens.TryValidate (token, out UserRegistrationTokens.RegistrationData regData)) { 34 SendE rrorResult(_context, HttpStatusCode.NotFound, null, "INVALID_OR_EXPIRED_TOKEN");34 SendEmptyResponse (_context, HttpStatusCode.NotFound, null, "INVALID_OR_EXPIRED_TOKEN"); 35 35 return; 36 36 } … … 50 50 51 51 protected override void HandleRestPost (RequestContext _context, IDictionary<string, object> _jsonInput, byte[] _jsonInputData) { 52 if (! TryGetJsonField (_jsonInput, "token", out string token)) {53 SendE rrorResult(_context, HttpStatusCode.BadRequest, _jsonInputData, "MISSING_TOKEN");52 if (!JsonCommons.TryGetJsonField (_jsonInput, "token", out string token)) { 53 SendEmptyResponse (_context, HttpStatusCode.BadRequest, _jsonInputData, "MISSING_TOKEN"); 54 54 return; 55 55 } 56 56 57 if (! TryGetJsonField (_jsonInput, "username", out string username)) {58 SendE rrorResult(_context, HttpStatusCode.BadRequest, _jsonInputData, "MISSING_USERNAME");57 if (!JsonCommons.TryGetJsonField (_jsonInput, "username", out string username)) { 58 SendEmptyResponse (_context, HttpStatusCode.BadRequest, _jsonInputData, "MISSING_USERNAME"); 59 59 return; 60 60 } 61 61 62 if (! TryGetJsonField (_jsonInput, "password", out string password)) {63 SendE rrorResult(_context, HttpStatusCode.BadRequest, _jsonInputData, "MISSING_PASSWORD");62 if (!JsonCommons.TryGetJsonField (_jsonInput, "password", out string password)) { 63 SendEmptyResponse (_context, HttpStatusCode.BadRequest, _jsonInputData, "MISSING_PASSWORD"); 64 64 return; 65 65 } 66 66 67 67 if (!UserRegistrationTokens.TryValidate (token, out UserRegistrationTokens.RegistrationData regData)) { 68 SendE rrorResult(_context, HttpStatusCode.Unauthorized, null, "INVALID_OR_EXPIRED_TOKEN");68 SendEmptyResponse (_context, HttpStatusCode.Unauthorized, null, "INVALID_OR_EXPIRED_TOKEN"); 69 69 return; 70 70 } 71 71 72 72 if (!userValidationRegex.IsMatch (username)) { 73 SendE rrorResult(_context, HttpStatusCode.Unauthorized, _jsonInputData, "INVALID_USERNAME");73 SendEmptyResponse (_context, HttpStatusCode.Unauthorized, _jsonInputData, "INVALID_USERNAME"); 74 74 return; 75 75 } 76 76 77 77 if (!passValidationRegex.IsMatch (password)) { 78 SendE rrorResult(_context, HttpStatusCode.Unauthorized, _jsonInputData, "INVALID_PASSWORD");78 SendEmptyResponse (_context, HttpStatusCode.Unauthorized, _jsonInputData, "INVALID_PASSWORD"); 79 79 return; 80 80 } … … 86 86 !PlatformUserIdentifierAbs.Equals (existingMapping.CrossPlatformUser, regData.CrossPlatformUserId)) { 87 87 // Username already in use by another player 88 SendE rrorResult(_context, HttpStatusCode.Unauthorized, _jsonInputData, "DUPLICATE_USERNAME");88 SendEmptyResponse (_context, HttpStatusCode.Unauthorized, _jsonInputData, "DUPLICATE_USERNAME"); 89 89 return; 90 90 }
Note:
See TracChangeset
for help on using the changeset viewer.