protected async UniTaskVoid HandleRequestUserRegister( RequestHandlerData requestHandler, RequestUserRegisterMessage request, RequestProceedResultDelegate <ResponseUserRegisterMessage> result) { #if UNITY_STANDALONE && !CLIENT_BUILD if (disableDefaultLogin) { result.InvokeError(new ResponseUserRegisterMessage() { message = UITextKeys.UI_ERROR_SERVICE_NOT_AVAILABLE }); return; } string username = request.username.Trim(); string password = request.password.Trim(); string email = request.email.Trim(); if (!NameValidating.ValidateUsername(username)) { result.InvokeError(new ResponseUserRegisterMessage() { message = UITextKeys.UI_ERROR_INVALID_USERNAME }); return; } if (requireEmail) { if (string.IsNullOrEmpty(email) || !Email.IsValid(email)) { result.InvokeError(new ResponseUserRegisterMessage() { message = UITextKeys.UI_ERROR_INVALID_EMAIL, }); return; } AsyncResponseData <FindEmailResp> findEmailResp = await DbServiceClient.FindEmailAsync(new FindEmailReq() { Email = email }); if (!findEmailResp.IsSuccess) { result.InvokeError(new ResponseUserRegisterMessage() { message = UITextKeys.UI_ERROR_INTERNAL_SERVER_ERROR, }); return; } if (findEmailResp.Response.FoundAmount > 0) { result.InvokeError(new ResponseUserRegisterMessage() { message = UITextKeys.UI_ERROR_EMAIL_ALREADY_IN_USE, }); return; } } AsyncResponseData <FindUsernameResp> findUsernameResp = await DbServiceClient.FindUsernameAsync(new FindUsernameReq() { Username = username }); if (!findUsernameResp.IsSuccess) { result.InvokeError(new ResponseUserRegisterMessage() { message = UITextKeys.UI_ERROR_INTERNAL_SERVER_ERROR, }); return; } if (findUsernameResp.Response.FoundAmount > 0) { result.InvokeError(new ResponseUserRegisterMessage() { message = UITextKeys.UI_ERROR_USERNAME_EXISTED, }); return; } if (string.IsNullOrEmpty(username) || username.Length < minUsernameLength) { result.InvokeError(new ResponseUserRegisterMessage() { message = UITextKeys.UI_ERROR_USERNAME_TOO_SHORT, }); return; } if (username.Length > maxUsernameLength) { result.InvokeError(new ResponseUserRegisterMessage() { message = UITextKeys.UI_ERROR_USERNAME_TOO_LONG, }); return; } if (string.IsNullOrEmpty(password) || password.Length < minPasswordLength) { result.InvokeError(new ResponseUserRegisterMessage() { message = UITextKeys.UI_ERROR_PASSWORD_TOO_SHORT, }); return; } AsyncResponseData <EmptyMessage> createResp = await DbServiceClient.CreateUserLoginAsync(new CreateUserLoginReq() { Username = username, Password = password, Email = email, }); if (!createResp.IsSuccess) { result.InvokeError(new ResponseUserRegisterMessage() { message = UITextKeys.UI_ERROR_INTERNAL_SERVER_ERROR, }); return; } // Response result.InvokeSuccess(new ResponseUserRegisterMessage()); #endif }