Add missing handling for sessions that are already verified.
This commit is contained in:
parent
b8e81e6677
commit
36846301de
3 changed files with 21 additions and 3 deletions
|
@ -384,6 +384,7 @@ object RegistrationRepository {
|
|||
*/
|
||||
suspend fun registerAccount(context: Context, sessionId: String?, registrationData: RegistrationData, pin: String? = null, masterKeyProducer: VerifyAccountRepository.MasterKeyProducer? = null): RegisterAccountResult =
|
||||
withContext(Dispatchers.IO) {
|
||||
Log.v(TAG, "registerAccount()")
|
||||
val api: RegistrationApi = AccountManagerFactory.getInstance().createUnauthenticated(context, registrationData.e164, SignalServiceAddress.DEFAULT_DEVICE_ID, registrationData.password).registrationApi
|
||||
|
||||
val universalUnidentifiedAccess: Boolean = TextSecurePreferences.isUniversalUnidentifiedAccess(context)
|
||||
|
|
|
@ -357,6 +357,12 @@ class RegistrationViewModel : ViewModel() {
|
|||
)
|
||||
Log.d(TAG, "SMS code request network call completed.")
|
||||
|
||||
if (codeRequestResponse is AlreadyVerified) {
|
||||
Log.d(TAG, "Got session was already verified when requesting SMS code.")
|
||||
registerVerifiedSession(context, sessionId)
|
||||
return
|
||||
}
|
||||
|
||||
handleSessionStateResult(context, codeRequestResponse)
|
||||
|
||||
if (codeRequestResponse is Success) {
|
||||
|
@ -792,6 +798,7 @@ class RegistrationViewModel : ViewModel() {
|
|||
}
|
||||
|
||||
private suspend fun registerVerifiedSession(context: Context, sessionId: String) {
|
||||
Log.v(TAG, "registerVerifiedSession()")
|
||||
val registrationData = getRegistrationData()
|
||||
val registrationResponse: RegisterAccountResult = RegistrationRepository.registerAccount(context, sessionId, registrationData)
|
||||
handleRegistrationResult(context, registrationData, registrationResponse, false)
|
||||
|
|
|
@ -3005,11 +3005,14 @@ public class PushServiceSocket {
|
|||
Log.e(TAG, "Unable to read response body.", e);
|
||||
throw new NonSuccessfulResponseCodeException(409);
|
||||
}
|
||||
if (response.pushChallengedRequired()) {
|
||||
if (response.getVerified()) {
|
||||
throw new AlreadyVerifiedException();
|
||||
} else if (response.pushChallengedRequired()) {
|
||||
throw new PushChallengeRequiredException();
|
||||
} else if (response.captchaRequired()) {
|
||||
throw new CaptchaRequiredException();
|
||||
} else {
|
||||
Log.i(TAG, "Received 409 in reg session handler that is not verified, with required information: " + String.join(", ", response.getRequestedInformation()));
|
||||
throw new HttpConflictException();
|
||||
}
|
||||
} else if (responseCode == 502) {
|
||||
|
@ -3045,11 +3048,14 @@ public class PushServiceSocket {
|
|||
Log.e(TAG, "Unable to read response body.", e);
|
||||
throw new NonSuccessfulResponseCodeException(409);
|
||||
}
|
||||
if (response.pushChallengedRequired()) {
|
||||
if (response.getVerified()) {
|
||||
throw new AlreadyVerifiedException();
|
||||
} else if (response.pushChallengedRequired()) {
|
||||
throw new PushChallengeRequiredException();
|
||||
} else if (response.captchaRequired()) {
|
||||
throw new CaptchaRequiredException();
|
||||
} else {
|
||||
Log.i(TAG, "Received 409 in for reg code request that is not verified, with required information: " + String.join(", ", response.getRequestedInformation()));
|
||||
throw new HttpConflictException();
|
||||
}
|
||||
} else if (responseCode == 418) {
|
||||
|
@ -3087,11 +3093,14 @@ public class PushServiceSocket {
|
|||
Log.e(TAG, "Unable to read response body.", e);
|
||||
throw new NonSuccessfulResponseCodeException(409);
|
||||
}
|
||||
if (response.pushChallengedRequired()) {
|
||||
if (response.getVerified()) {
|
||||
throw new AlreadyVerifiedException();
|
||||
} else if (response.pushChallengedRequired()) {
|
||||
throw new PushChallengeRequiredException();
|
||||
} else if (response.captchaRequired()) {
|
||||
throw new CaptchaRequiredException();
|
||||
} else {
|
||||
Log.i(TAG, "Received 409 for patching reg session that is not verified, with required information: " + String.join(", ", response.getRequestedInformation()));
|
||||
throw new HttpConflictException();
|
||||
}
|
||||
}
|
||||
|
@ -3121,6 +3130,7 @@ public class PushServiceSocket {
|
|||
// Note: this explicitly requires Verified to be false
|
||||
throw new MustRequestNewCodeException();
|
||||
} else {
|
||||
Log.i(TAG, "Received 409 for reg code submission that is not verified, with required information: " + String.join(", ", sessionMetadata.getRequestedInformation()));
|
||||
throw new HttpConflictException();
|
||||
}
|
||||
case 440:
|
||||
|
|
Loading…
Add table
Reference in a new issue