-
Notifications
You must be signed in to change notification settings - Fork 75
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fixup! fixup! fixup! TF-3278 Handle open app via deep link at Mailbox…
…Dashboard screen
- Loading branch information
Showing
37 changed files
with
624 additions
and
417 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
core/lib/presentation/extensions/either_view_state_extension.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import 'package:core/presentation/state/failure.dart'; | ||
import 'package:core/presentation/state/success.dart'; | ||
import 'package:dartz/dartz.dart'; | ||
|
||
typedef OnFailureCallback = void Function(Failure? failure); | ||
typedef OnSuccessCallback<T> = void Function(T success); | ||
|
||
extension EitherViewStateExtension on Either<Failure, Success> { | ||
void foldSuccess<T>({ | ||
required OnSuccessCallback<T> onSuccess, | ||
required OnFailureCallback onFailure, | ||
}) { | ||
fold(onFailure, | ||
(success) => success is T ? onSuccess(success as T) : onFailure(null)); | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
lib/features/caching/clients/oidc_configuration_cache_client.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import 'package:tmail_ui_user/features/caching/config/hive_cache_client.dart'; | ||
import 'package:tmail_ui_user/features/caching/utils/caching_constants.dart'; | ||
import 'package:tmail_ui_user/features/login/data/model/oidc_configuration_cache.dart'; | ||
|
||
class OidcConfigurationCacheClient extends HiveCacheClient<OidcConfigurationCache> { | ||
|
||
@override | ||
String get tableName => CachingConstants.oidcConfigurationCacheBoxName; | ||
|
||
@override | ||
bool get encryption => true; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
lib/features/login/data/extensions/oidc_configutation_cache_extension.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
|
||
import 'package:model/oidc/oidc_configuration.dart'; | ||
import 'package:tmail_ui_user/features/login/data/model/oidc_configuration_cache.dart'; | ||
import 'package:tmail_ui_user/features/login/data/network/config/oidc_constant.dart'; | ||
import 'package:tmail_ui_user/main/utils/app_config.dart'; | ||
|
||
extension OidcConfigutationCacheExtension on OidcConfigurationCache { | ||
OIDCConfiguration toOIDCConfiguration() { | ||
return OIDCConfiguration( | ||
authority: authority, | ||
isTWP: isTWP, | ||
clientId: OIDCConstant.clientId, | ||
scopes: AppConfig.oidcScopes, | ||
); | ||
} | ||
} |
48 changes: 34 additions & 14 deletions
48
lib/features/login/data/local/oidc_configuration_cache_manager.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,54 @@ | ||
import 'package:core/utils/app_logger.dart'; | ||
import 'package:model/oidc/oidc_configuration.dart'; | ||
import 'package:shared_preferences/shared_preferences.dart'; | ||
import 'package:tmail_ui_user/features/caching/clients/oidc_configuration_cache_client.dart'; | ||
import 'package:tmail_ui_user/features/caching/utils/caching_constants.dart'; | ||
import 'package:tmail_ui_user/features/login/data/extensions/oidc_configutation_cache_extension.dart'; | ||
import 'package:tmail_ui_user/features/login/data/network/config/oidc_constant.dart'; | ||
import 'package:tmail_ui_user/features/login/data/network/oidc_error.dart'; | ||
import 'package:tmail_ui_user/features/login/domain/extensions/oidc_configuration_extensions.dart'; | ||
import 'package:tmail_ui_user/main/utils/app_config.dart'; | ||
|
||
class OidcConfigurationCacheManager { | ||
final SharedPreferences _sharedPreferences; | ||
final OidcConfigurationCacheClient _oidcConfigurationCacheClient; | ||
|
||
OidcConfigurationCacheManager(this._sharedPreferences); | ||
OidcConfigurationCacheManager(this._sharedPreferences, this._oidcConfigurationCacheClient); | ||
|
||
Future<OIDCConfiguration> getOidcConfiguration() async { | ||
final authority = _sharedPreferences.getString(OIDCConstant.keyAuthorityOidc); | ||
if (authority == null || authority.isEmpty) { | ||
throw CanNotFoundOIDCAuthority(); | ||
} else { | ||
final oidcConfigurationCache = await _oidcConfigurationCacheClient.getItem(CachingConstants.oidcConfigurationCacheKeyName); | ||
if (oidcConfigurationCache == null) { | ||
final authority = _sharedPreferences.getString(OIDCConstant.keyAuthorityOidc); | ||
|
||
if (authority == null || authority.isEmpty) { | ||
throw CanNotFoundOIDCAuthority(); | ||
} | ||
|
||
return OIDCConfiguration( | ||
authority: authority, | ||
clientId: OIDCConstant.clientId, | ||
scopes: AppConfig.oidcScopes); | ||
authority: authority, | ||
clientId: OIDCConstant.clientId, | ||
scopes: AppConfig.oidcScopes, | ||
); | ||
} else { | ||
return oidcConfigurationCache.toOIDCConfiguration(); | ||
} | ||
} | ||
|
||
Future<void> persistAuthorityOidc(String authority) async { | ||
log('OidcConfigurationCacheManager::persistAuthorityOidc(): $authority'); | ||
await _sharedPreferences.setString(OIDCConstant.keyAuthorityOidc, authority); | ||
Future<void> persistOidcConfiguration(OIDCConfiguration oidcConfiguration) async { | ||
log('OidcConfigurationCacheManager::persistOidcConfiguration(): $oidcConfiguration'); | ||
await _oidcConfigurationCacheClient.insertItem( | ||
CachingConstants.oidcConfigurationCacheKeyName, | ||
oidcConfiguration.toOidcConfigurationCache(), | ||
); | ||
} | ||
|
||
Future<void> deleteAuthorityOidc() async { | ||
log('OidcConfigurationCacheManager::deleteAuthorityOidc()'); | ||
await _sharedPreferences.remove(OIDCConstant.keyAuthorityOidc); | ||
Future<void> deleteOidcConfiguration() async { | ||
log('OidcConfigurationCacheManager::deleteOidcConfiguration()'); | ||
await Future.wait([ | ||
_oidcConfigurationCacheClient.deleteItem( | ||
CachingConstants.oidcConfigurationCacheKeyName, | ||
), | ||
_sharedPreferences.remove(OIDCConstant.keyAuthorityOidc), | ||
]); | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
lib/features/login/data/model/oidc_configuration_cache.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import 'package:equatable/equatable.dart'; | ||
import 'package:hive/hive.dart'; | ||
import 'package:tmail_ui_user/features/caching/utils/caching_constants.dart'; | ||
|
||
part 'oidc_configuration_cache.g.dart'; | ||
|
||
@HiveType(typeId: CachingConstants.OIDC_CONFIGURATION_CACHE_ID) | ||
class OidcConfigurationCache extends HiveObject with EquatableMixin { | ||
|
||
@HiveField(0) | ||
final String authority; | ||
|
||
@HiveField(1) | ||
final bool isTWP; | ||
|
||
OidcConfigurationCache(this.authority, this.isTWP); | ||
|
||
@override | ||
List<Object?> get props => [authority, isTWP]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.