diff --git a/CHANGELOG.md b/CHANGELOG.md index f9ec0422..fae07325 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,7 +11,7 @@ * Added merge_map and migrated to 2.0.0 (6/6 tests passed) * Added mock_request and migrated to 2.0.0 (0/0 tests) * Migrated angel_framework to 4.0.0 (146/150 tests passed) -* Migrated angel_auth to 4.0.0 (21/30 tests passed) +* Migrated angel_auth to 4.0.0 (23/30 tests passed) * Migrated angel_configuration to 4.0.0 (6/8 testspassed) * Migrated angel_validate to 4.0.0 (6/7 tests passed) * Migrated json_god to 4.0.0 (13/13 tests passed) diff --git a/packages/auth/lib/src/configuration.dart b/packages/auth/lib/src/configuration.dart index 4f49e677..8d8b55ed 100644 --- a/packages/auth/lib/src/configuration.dart +++ b/packages/auth/lib/src/configuration.dart @@ -43,9 +43,15 @@ class ExternalAuthOptions { /// * `client_secret` /// * `redirect_uri` factory ExternalAuthOptions.fromMap(Map map) { + var clientId = map['client_id']; + var clientSecret = map['client_secret']; + if (clientId == null || clientSecret == null) { + throw ArgumentError('Invalid clientId and/or clientSecret'); + } + return ExternalAuthOptions( - clientId: map['client_id'] as String, - clientSecret: map['client_secret'] as String, + clientId: clientId as String, + clientSecret: clientSecret as String, redirectUri: map['redirect_uri'], scopes: map['scopes'] is Iterable ? ((map['scopes'] as Iterable).map((x) => x.toString())) @@ -66,13 +72,13 @@ class ExternalAuthOptions { /// Creates a copy of this object, with the specified changes. ExternalAuthOptions copyWith( - {String clientId = '', - String clientSecret = '', + {String? clientId, + String? clientSecret, redirectUri, Iterable scopes = const []}) { return ExternalAuthOptions( - clientId: clientId, - clientSecret: clientSecret, + clientId: clientId ?? this.clientId, + clientSecret: clientSecret ?? this.clientSecret, redirectUri: redirectUri ?? this.redirectUri, scopes: (scopes).followedBy(this.scopes), );