activateUserAccount static method
Implementation
static Future<Result<dynamic>> activateUserAccount(
String id, String url, String password, String token) async {
final result = await checkKwikpassHealth();
if(result.isSuccess) {
final healthData = result.getDataOrThrow();
if(healthData?.isKwikpassHealthy == false){
throw Exception('Kwikpass is unhealthy');
}
}
final data = {
'form_type': 'activate_customer_password',
'utf8': '✓',
'customer[password]': password,
'customer[password_confirmation]': password,
'token': token,
'id': id,
};
try {
// Sent only once, and skipped when no phone is known.
await _sendPhoneEvent({
'category': 'login_modal',
'label': 'account_activated',
'action': 'automated',
}, await getUserPhone());
final response = await Dio(BaseOptions(
connectTimeout: DioClient.requestTimeout,
sendTimeout: DioClient.requestTimeout,
receiveTimeout: DioClient.requestTimeout,
)).post(
'https://$url/account/activate',
data: data,
options: Options(
headers: {'Content-Type': 'application/x-www-form-urlencoded'},
followRedirects: false,
),
);
return Success(response);
} catch (err) {
final apiError = handleApiError(err);
return apiError;
}
}