fc4a4792c3
Signed-off-by: dab246 <tdvu@linagora.com> (cherry picked from commit 3fff318bbe66a5f4387c25d18e0d2a9480719d72)
51 lines
1.4 KiB
Dart
51 lines
1.4 KiB
Dart
import 'package:jmap_dart_client/jmap/account_id.dart';
|
|
import 'package:jmap_dart_client/jmap/core/id.dart';
|
|
import 'package:jmap_dart_client/jmap/core/user_name.dart';
|
|
import 'package:model/account/authentication_type.dart';
|
|
import 'package:model/account/personal_account.dart';
|
|
import 'package:tmail_ui_user/features/login/data/model/account_cache.dart';
|
|
|
|
extension AccountCacheExtension on AccountCache {
|
|
AuthenticationType fromAuthenticationTypeString() {
|
|
if (authenticationType == 'basic') {
|
|
return AuthenticationType.basic;
|
|
} else if (authenticationType == 'oidc') {
|
|
return AuthenticationType.oidc;
|
|
} else {
|
|
return AuthenticationType.none;
|
|
}
|
|
}
|
|
|
|
PersonalAccount toAccount() {
|
|
final authenticationType = fromAuthenticationTypeString();
|
|
return PersonalAccount(
|
|
id,
|
|
authenticationType,
|
|
isSelected: isSelected,
|
|
accountId: accountId != null ? AccountId(Id(accountId!)) : null,
|
|
apiUrl: apiUrl,
|
|
userName: userName != null ? UserName(userName!) : null);
|
|
}
|
|
|
|
AccountCache unselected() {
|
|
return AccountCache(
|
|
id,
|
|
authenticationType,
|
|
isSelected: false,
|
|
accountId: accountId,
|
|
apiUrl: apiUrl,
|
|
userName: userName
|
|
);
|
|
}
|
|
|
|
AccountCache emptyId() {
|
|
return AccountCache(
|
|
'',
|
|
authenticationType,
|
|
isSelected: false,
|
|
accountId: accountId,
|
|
apiUrl: apiUrl,
|
|
userName: userName
|
|
);
|
|
}
|
|
} |