Skip to content

Commit

Permalink
feat: Add enterprise wallet attestation only once #2451
Browse files Browse the repository at this point in the history
  • Loading branch information
bibash28 committed Feb 29, 2024
1 parent a2555bf commit ce3463f
Show file tree
Hide file tree
Showing 7 changed files with 62 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -155,4 +155,7 @@ enum ResponseString {
RESPONSE_STRING_theCredentialOfferIsInvalid,
RESPONSE_STRING_theServiceIsNotAvailable,
RESPONSE_STRING_theIssuanceOfThisCredentialIsPending,
RESPONSE_STRING_successfullyAddedEnterpriseAccount,

RESPONSE_STRING_successfullyUpdatedEnterpriseAccount,
}
Original file line number Diff line number Diff line change
Expand Up @@ -490,6 +490,13 @@ extension ResponseStringX on ResponseString {
case ResponseString.RESPONSE_STRING_theIssuanceOfThisCredentialIsPending:
return globalMessage
.RESPONSE_STRING_theIssuanceOfThisCredentialIsPending;

case ResponseString.RESPONSE_STRING_successfullyAddedEnterpriseAccount:
return globalMessage.RESPONSE_STRING_successfullyAddedEnterpriseAccount;

case ResponseString.RESPONSE_STRING_successfullyUpdatedEnterpriseAccount:
return globalMessage
.RESPONSE_STRING_successfullyUpdatedEnterpriseAccount;
}
}
}
4 changes: 4 additions & 0 deletions lib/app/shared/message_handler/global_message.dart
Original file line number Diff line number Diff line change
Expand Up @@ -384,4 +384,8 @@ class GlobalMessage {
l10n.theServiceIsNotAvailable;
String get RESPONSE_STRING_theIssuanceOfThisCredentialIsPending =>
l10n.theIssuanceOfThisCredentialIsPending;
String get RESPONSE_STRING_successfullyAddedEnterpriseAccount =>
l10n.successfullyAddedEnterpriseAccount;
String get RESPONSE_STRING_successfullyUpdatedEnterpriseAccount =>
l10n.successfullyUpdatedEnterpriseAccount;
}
13 changes: 13 additions & 0 deletions lib/app/shared/message_handler/response_message.dart
Original file line number Diff line number Diff line change
Expand Up @@ -752,6 +752,19 @@ class ResponseMessage with MessageHandler {
.RESPONSE_STRING_theIssuanceOfThisCredentialIsPending.localise(
context,
);

case ResponseString.RESPONSE_STRING_successfullyAddedEnterpriseAccount:
return ResponseString
.RESPONSE_STRING_successfullyAddedEnterpriseAccount.localise(
context,
);

case ResponseString
.RESPONSE_STRING_successfullyUpdatedEnterpriseAccount:
return ResponseString
.RESPONSE_STRING_successfullyUpdatedEnterpriseAccount.localise(
context,
);
}
}
return '';
Expand Down
41 changes: 20 additions & 21 deletions lib/enterprise/cubit/enterprise_cubit.dart
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,16 @@ class EnterpriseCubit extends Cubit<EnterpriseState> {
);
}

final savedEmail = await profileCubit.secureStorageProvider.get(
SecureStorageKeys.enterpriseEmail,
);

if (savedEmail != null && email == savedEmail) {
/// if email is matched then update the configuration
await updateTheConfiguration();
return;
}

/// get vc and store it in the wallet
final walletAttestationData = await getWalletAttestationData(url);

Expand Down Expand Up @@ -79,8 +89,11 @@ class EnterpriseCubit extends Cubit<EnterpriseState> {

emit(
state.copyWith(
message: const StateMessage.success(
stringMessage: 'Successfully upgraded to enterprise account!',
message: StateMessage.success(
messageHandler: ResponseMessage(
message: ResponseString
.RESPONSE_STRING_successfullyAddedEnterpriseAccount,
),
),
),
);
Expand Down Expand Up @@ -274,23 +287,6 @@ class EnterpriseCubit extends Cubit<EnterpriseState> {
try {
emit(state.loading());

// final email = await profileCubit.secureStorageProvider.get(
// SecureStorageKeys.enterpriseEmail,
// );

// final password = await profileCubit.secureStorageProvider.get(
// SecureStorageKeys.enterprisePassword,
// );

// if (email == null || password == null) {
// throw ResponseMessage(
// data: {
// 'error': 'invalid_request',
// 'error_description': 'The email or password is missing.',
// },
// );
// }

final provider = await profileCubit.secureStorageProvider.get(
SecureStorageKeys.enterpriseWalletProvider,
);
Expand Down Expand Up @@ -375,8 +371,11 @@ class EnterpriseCubit extends Cubit<EnterpriseState> {
emit(
state.copyWith(
status: AppStatus.success,
message: const StateMessage.success(
stringMessage: 'Successfully upgdated enterprise account!',
message: StateMessage.success(
messageHandler: ResponseMessage(
message: ResponseString
.RESPONSE_STRING_successfullyUpdatedEnterpriseAccount,
),
),
),
);
Expand Down
4 changes: 3 additions & 1 deletion lib/l10n/arb/app_en.arb
Original file line number Diff line number Diff line change
Expand Up @@ -1038,5 +1038,7 @@
"thisTypeProofCannotBeUsedWithThisVCFormat": "This type proof cannot be used with this VC Format.",
"enterprise": "Enterprise",
"oWFBaselineProfile": "OWF Baseline Profile",
"defaultProfile":"Default"
"defaultProfile":"Default",
"successfullyAddedEnterpriseAccount": "Successfully added enterprise account!",
"successfullyUpdatedEnterpriseAccount": "Successfully updated enterprise account!"
}
16 changes: 12 additions & 4 deletions lib/l10n/untranslated.json
Original file line number Diff line number Diff line change
Expand Up @@ -943,7 +943,9 @@
"thisTypeProofCannotBeUsedWithThisVCFormat",
"enterprise",
"oWFBaselineProfile",
"defaultProfile"
"defaultProfile",
"successfullyAddedEnterpriseAccount",
"successfullyUpdatedEnterpriseAccount"
],

"es": [
Expand Down Expand Up @@ -1890,12 +1892,16 @@
"thisTypeProofCannotBeUsedWithThisVCFormat",
"enterprise",
"oWFBaselineProfile",
"defaultProfile"
"defaultProfile",
"successfullyAddedEnterpriseAccount",
"successfullyUpdatedEnterpriseAccount"
],

"fr": [
"blockchainCardsDiscoverTitle",
"blockchainCardsDiscoverSubtitle"
"blockchainCardsDiscoverSubtitle",
"successfullyAddedEnterpriseAccount",
"successfullyUpdatedEnterpriseAccount"
],

"it": [
Expand Down Expand Up @@ -2842,6 +2848,8 @@
"thisTypeProofCannotBeUsedWithThisVCFormat",
"enterprise",
"oWFBaselineProfile",
"defaultProfile"
"defaultProfile",
"successfullyAddedEnterpriseAccount",
"successfullyUpdatedEnterpriseAccount"
]
}

0 comments on commit ce3463f

Please sign in to comment.