Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 6 additions & 15 deletions lib/licensing/license_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -141,19 +141,14 @@ class LicenseService {
throw LicenseException(msg, code);
}

final dataObj = body['data'];
if (dataObj is! Map<String, dynamic>) {
throw const LicenseException('Invalid response from licensing server', 'INVALID_RESPONSE');
}
final data = dataObj;
final jwt = data['token'] as String?;
final jwt = body['token'] as String?;
if (jwt == null) {
throw const LicenseException('Invalid response from licensing server', 'INVALID_RESPONSE');
}
await _persist(jwt);

final tier = _parseTier(data['tier'] as String? ?? 'free');
final features = _parseFeatures(data['features']);
final tier = _parseTier(body['tier'] as String? ?? 'free');
final features = _parseFeatures(body['features']);
return LicenseState(
status: LicenseStatus.active,
tier: tier,
Expand Down Expand Up @@ -190,13 +185,9 @@ class LicenseService {
if (resp.statusCode == 200) {
if (decoded is Map<String, dynamic>) {
final body = decoded;
final dataObj = body['data'];
if (dataObj is Map<String, dynamic>) {
final data = dataObj;
final newJwt = data['token'] as String?;
if (newJwt != null) {
await _persist(newJwt);
}
final newJwt = body['token'] as String?;
if (newJwt != null) {
await _persist(newJwt);
}
}
return loadCachedState();
Expand Down
Loading