diff --git a/c-sharp/JsonUtils/RegistrationDataConverter.cs b/c-sharp/JsonUtils/RegistrationDataConverter.cs
index d682ed6ad2..4ad0571635 100644
--- a/c-sharp/JsonUtils/RegistrationDataConverter.cs
+++ b/c-sharp/JsonUtils/RegistrationDataConverter.cs
@@ -23,14 +23,19 @@ JsonSerializerOptions options
string supporterName = "";
string? lastPropertyName = null;
- while (reader.Read())
+ // The starting token is consumed before we get the reader
+ int onObjectLevel = 1;
+ while (onObjectLevel > 0 && reader.Read())
{
switch (reader.TokenType)
{
case JsonTokenType.StartObject:
- case JsonTokenType.EndObject:
case JsonTokenType.StartArray:
+ onObjectLevel++;
+ break;
+ case JsonTokenType.EndObject:
case JsonTokenType.EndArray:
+ onObjectLevel--;
break;
case JsonTokenType.PropertyName:
lastPropertyName = reader.GetString();
diff --git a/c-sharp/Users/ParatextRegistrationService.cs b/c-sharp/Users/ParatextRegistrationService.cs
index b2d4284373..67df242123 100644
--- a/c-sharp/Users/ParatextRegistrationService.cs
+++ b/c-sharp/Users/ParatextRegistrationService.cs
@@ -45,16 +45,16 @@ await PapiClient.RegisterRequestHandlerAsync(
#endregion
- #region Protected properties and methods
+ #region Private properties and methods
- protected PapiClient PapiClient { get; } = papiClient;
+ private PapiClient PapiClient { get; } = papiClient;
///
/// Returns information about user's current Paratext Registry user information in ParatextData.dll
///
/// Contents of command request. No contents expected
/// Paratext registration information
- protected RegistrationData GetParatextRegistrationData()
+ private RegistrationData GetParatextRegistrationData()
{
try
{
@@ -86,7 +86,7 @@ protected RegistrationData GetParatextRegistrationData()
///
/// Contents of command request. Array whose first entry is the registration data object
/// `true` if successfully updated; `false` otherwise
- protected void SetParatextRegistrationData(RegistrationData newRegistrationData)
+ private void SetParatextRegistrationData(RegistrationData newRegistrationData)
{
bool shouldSkipAppendingToExceptionMessage = false;
try
@@ -154,6 +154,7 @@ protected void SetParatextRegistrationData(RegistrationData newRegistrationData)
!string.IsNullOrEmpty(RegistrationInfo.DefaultUser.Name)
&& RegistrationInfo.DefaultUser.Name != newRegistrationData.Name
)
+ {
try
{
PrepareForUserChange();
@@ -164,6 +165,7 @@ protected void SetParatextRegistrationData(RegistrationData newRegistrationData)
$"Exception while committing existing changes to prepare to change users: {e}"
);
}
+ }
// Actually change the registration info
RegistrationInfo.ChangeRegistrationData(newRegistrationData);
@@ -171,28 +173,16 @@ protected void SetParatextRegistrationData(RegistrationData newRegistrationData)
// registration code may have changed, so reset the registry server with the new user data
RegistryServer.Default?.ResetServer(RegistrationInfo.DefaultUser);
- // No need to observe this task in any way. We are scheduling a call to restart the application then
- // returning from this method to continue execution and properly return from this method.
-#pragma warning disable VSTHRD110 // Observe result of async calls
// Restart the application after a delay. Don't wait for it so the response goes through
- Task.Delay(REGISTRATION_CHANGE_RESTART_DELAY_MS)
- .ContinueWith(
- async (Task task) =>
- {
- try
- {
- await PapiClient.SendRequestAsync("command:platform.restart", []);
- }
- catch (Exception e)
- {
- Console.WriteLine(
- $"Error while requesting to restart the application: {e}"
- );
- }
- },
- TaskScheduler.Default
- );
-#pragma warning restore VSTHRD110 // Observe result of async calls
+ ThreadingUtils.RunTask(
+ Task.Delay(REGISTRATION_CHANGE_RESTART_DELAY_MS)
+ .ContinueWith(
+ async (Task task) =>
+ await PapiClient.SendRequestAsync("command:platform.restart", []),
+ TaskScheduler.Default
+ ),
+ "ParatextRegistrationService sending request to restart the application"
+ );
}
catch (Exception e)
{
@@ -205,15 +195,11 @@ protected void SetParatextRegistrationData(RegistrationData newRegistrationData)
}
}
- #endregion
-
- #region Private properties and methods
-
///
/// For any project with uncommitted changes on this machine, marks a point in project history in
/// preparation for switching to a different Paratext user.
///
- /// Adapted from `UserSwitchingHelper.PrepareForUserChange
+ /// Adapted from `UserSwitchingHelper.PrepareForUserChange`
///
private void PrepareForUserChange()
{
diff --git a/extensions/src/paratext-registration/src/paratext-registration.web-view.tsx b/extensions/src/paratext-registration/src/paratext-registration.web-view.tsx
index c06d5adb29..d95b04a933 100644
--- a/extensions/src/paratext-registration/src/paratext-registration.web-view.tsx
+++ b/extensions/src/paratext-registration/src/paratext-registration.web-view.tsx
@@ -26,7 +26,8 @@ enum SaveState {
const REGISTRATION_CODE_LENGTH_WITH_DASHES = 34;
const REGISTRATION_CODE_REGEX_STRING =
- '^(?:[a-zA-Z0-9]{6}-[a-zA-Z0-9]{6}-[a-zA-Z0-9]{6}-[a-zA-Z0-9]{6}-[a-zA-Z0-9]{6}|\\*\\*\\*\\*\\*\\*-\\*\\*\\*\\*\\*\\*-\\*\\*\\*\\*\\*\\*-\\*\\*\\*\\*\\*\\*-\\*\\*\\*\\*\\*\\*)$';
+ '^(?:[a-zA-Z0-9]{6}-[a-zA-Z0-9]{6}-[a-zA-Z0-9]{6}-[a-zA-Z0-9]{6}-[a-zA-Z0-9]{6}|\\*{6}-\\*{6}-\\*{6}-\\*{6}-\\*{6})$';
+const EMAIL_REGEX_STRING = '^.+@.+\\..+$';
/** Just a div with some margins to give some space around parts of the web view */
function Section({ children, className }: GenericComponentProps) {
@@ -138,8 +139,9 @@ globalThis.webViewComponent = function ParatextRegistration({ useWebViewState }:
currentRegistrationData.code !== registrationCode ||
currentRegistrationData.email !== email ||
currentRegistrationData.supporterName !== supporter;
- // whether the code seems valid according to a quick check
+ // whether the code and email seem valid according to a quick check
const isCodeValid = !!registrationCode.match(REGISTRATION_CODE_REGEX_STRING);
+ const isEmailValid = !!email.match(EMAIL_REGEX_STRING);
return (