Skip to content

Commit

Permalink
update enterprise #2447
Browse files Browse the repository at this point in the history
  • Loading branch information
bibash28 committed Feb 29, 2024
1 parent c6c3c69 commit 4dd4245
Show file tree
Hide file tree
Showing 8 changed files with 26 additions and 493 deletions.
9 changes: 5 additions & 4 deletions lib/dashboard/drawer/src/view/drawer_page.dart
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import 'package:altme/app/app.dart';
import 'package:altme/dashboard/dashboard.dart';
import 'package:altme/dashboard/drawer/profile/view/pick_profile_menu.dart';
import 'package:altme/enterprise/cubit/enterprise_cubit.dart';
import 'package:altme/l10n/l10n.dart';
import 'package:altme/onboarding/onboarding.dart';
import 'package:altme/theme/theme.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
Expand Down Expand Up @@ -57,9 +57,10 @@ class DrawerView extends StatelessWidget {
DrawerCategoryItem(
title: l10n.updateYourWalletConfigNow,
padding: const EdgeInsets.all(16),
onClick: () {
Navigator.of(context)
.push<void>(EnterpriseUpdatePage.route());
onClick: () async {
await context
.read<EnterpriseCubit>()
.updateTheConfiguration();
},
),
const SizedBox(height: Sizes.spaceSmall),
Expand Down
51 changes: 21 additions & 30 deletions lib/enterprise/cubit/enterprise_cubit.dart
Original file line number Diff line number Diff line change
Expand Up @@ -270,39 +270,32 @@ class EnterpriseCubit extends Cubit<EnterpriseState> {
return jwtVc;
}

Future<void> updateTheConfiguration(String scannedResponse) async {
Future<void> updateTheConfiguration() async {
try {
emit(state.loading());
final uri = Uri.parse(scannedResponse);

final String? url = uri.queryParameters['wallet-provider'];
// final email = await profileCubit.secureStorageProvider.get(
// SecureStorageKeys.enterpriseEmail,
// );

if (url == null) {
throw Exception();
}
// final password = await profileCubit.secureStorageProvider.get(
// SecureStorageKeys.enterprisePassword,
// );

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.',
},
);
}
// 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.enterpriseProfileSetting,
SecureStorageKeys.enterpriseWalletProvider,
);

if (provider == null || provider != url) {
if (provider == null) {
throw ResponseMessage(
data: {
'error': 'invalid_request',
Expand All @@ -311,17 +304,13 @@ class EnterpriseCubit extends Cubit<EnterpriseState> {
);
}

final encodedData = utf8.encode('$email:$password');
final base64Encoded = base64UrlEncode(encodedData).replaceAll('=', '');

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

final headers = <String, dynamic>{
'Content-Type': 'application/x-www-form-urlencoded',
'Authorization': 'Basic $base64Encoded',
};

final data = <String, dynamic>{
Expand All @@ -330,7 +319,7 @@ class EnterpriseCubit extends Cubit<EnterpriseState> {
};

final response = await client.post(
'$url/update',
'$provider/update',
headers: headers,
data: data,
);
Expand Down Expand Up @@ -386,7 +375,9 @@ class EnterpriseCubit extends Cubit<EnterpriseState> {
emit(
state.copyWith(
status: AppStatus.success,
message: null,
message: const StateMessage.success(
stringMessage: 'Successfully upgdated enterprise account!',
),
),
);
} catch (e) {
Expand Down
1 change: 0 additions & 1 deletion lib/onboarding/enterprise/enterprise.dart

This file was deleted.

182 changes: 0 additions & 182 deletions lib/onboarding/enterprise/update/cubit/update_cubit.dart

This file was deleted.

63 changes: 0 additions & 63 deletions lib/onboarding/enterprise/update/cubit/update_state.dart

This file was deleted.

2 changes: 0 additions & 2 deletions lib/onboarding/enterprise/update/update.dart

This file was deleted.

Loading

0 comments on commit 4dd4245

Please sign in to comment.