Connect sign-up to Sendico Facts intake (#46)

This commit is contained in:
Stephan D committed 2026-10-15 00:55:19 +02:00
1 parent 30f0455122
commit a584c8189a
40 files changed
+1616 -35

No files matched your search

@@ -63,6 +63,7 @@ class BackendAuthServices
String path,
Map<String, Object?> body, {
bool factor = false,
bool verification = false,
}) async {
try {
final uri = baseUri.replace(
@@ -81,6 +82,7 @@ class BackendAuthServices
.timeout(const Duration(seconds: 15));
final dto = BackendDTO.decode(res.body);
if (res.statusCode < 200 || res.statusCode >= 300) {
if (verification) throw BackendMapper.verificationFailure(dto);
throw factor
? BackendMapper.factorFailure(res.statusCode, dto)
: BackendMapper.authFailure(res.statusCode, dto);
@@ -90,7 +92,11 @@ class BackendAuthServices
rethrow;
} on FactorException {
rethrow;
} on VerificationException {
rethrow;
} catch (_) {
if (verification)
throw const VerificationException(VerificationError.internal);
if (factor) throw const FactorException(FactorError.unavailable);
throw const AuthException(AuthError.unavailable);
}
@@ -148,16 +154,17 @@ class BackendAuthServices
await _post('verification/send', {
'email': normalized,
'idempotencyKey': key,
}, factor: true);
}, verification: true);
_retryKeys.remove('activation:$normalized');
return VerificationMapper.fromDTO(
const VerificationDTO(simulated: false),
);
} on FactorException catch (e) {
if (e.code == FactorError.expired || e.code == FactorError.invalid) {
} on VerificationException catch (e) {
if (e.code == VerificationError.expired ||
e.code == VerificationError.invalid) {
_retryKeys.remove('activation:$normalized');
}
throw const VerificationException(VerificationError.internal);
rethrow;
} catch (_) {
throw const VerificationException(VerificationError.internal);
}
@@ -165,18 +172,8 @@ class BackendAuthServices
@override
Future<VerificationResult> confirm({required String token}) async {
try {
await _post('verification/confirm', {'token': token}, factor: true);
return VerificationMapper.fromDTO(
const VerificationDTO(simulated: false),
);
} on FactorException catch (e) {
throw VerificationException(switch (e.code) {
FactorError.expired => VerificationError.expired,
FactorError.invalid => VerificationError.invalid,
_ => VerificationError.internal,
});
}
await _post('verification/confirm', {'token': token}, verification: true);
return VerificationMapper.fromDTO(const VerificationDTO(simulated: false));
}
@override