Skip to content

Commit

Permalink
feat: Show Wrong pin code message #1902
Browse files Browse the repository at this point in the history
  • Loading branch information
bibash28 committed Sep 14, 2023
1 parent 586f649 commit 58cdfde
Show file tree
Hide file tree
Showing 8 changed files with 63 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -154,4 +154,5 @@ enum ResponseString {
RESPONSE_STRING_theCredentialIsNotReady,
RESPONSE_STRING_theCredentialIsNoMoreReady,
RESPONSE_STRING_theRequestIsRejected,
RESPONSE_STRING_userPinIsIncorrect,
}
Original file line number Diff line number Diff line change
Expand Up @@ -486,6 +486,9 @@ extension ResponseStringX on ResponseString {

case ResponseString.RESPONSE_STRING_theRequestIsRejected:
return globalMessage.RESPONSE_STRING_theRequestIsRejected;

case ResponseString.RESPONSE_STRING_userPinIsIncorrect:
return globalMessage.RESPONSE_STRING_userPinIsIncorrect;
}
}
}
1 change: 1 addition & 0 deletions lib/app/shared/message_handler/global_message.dart
Original file line number Diff line number Diff line change
Expand Up @@ -386,4 +386,5 @@ class GlobalMessage {
String get RESPONSE_STRING_theCredentialIsNoMoreReady =>
l10n.theCredentialIsNoMoreReady;
String get RESPONSE_STRING_theRequestIsRejected => l10n.theRequestIsRejected;
String get RESPONSE_STRING_userPinIsIncorrect => l10n.userPinIsIncorrect;
}
5 changes: 5 additions & 0 deletions lib/app/shared/message_handler/response_message.dart
Original file line number Diff line number Diff line change
Expand Up @@ -723,6 +723,11 @@ class ResponseMessage with MessageHandler {
return ResponseString.RESPONSE_STRING_theRequestIsRejected.localise(
context,
);

case ResponseString.RESPONSE_STRING_userPinIsIncorrect:
return ResponseString.RESPONSE_STRING_userPinIsIncorrect.localise(
context,
);
}
}
return '';
Expand Down
40 changes: 33 additions & 7 deletions lib/dashboard/qr_code/qr_code_scan/cubit/qr_code_scan_cubit.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1015,17 +1015,43 @@ class QRCodeScanCubit extends Cubit<QRCodeScanState> {
oidc4vc.resetNonceAndAccessTokenAndAuthorizationDetails();
goBack();
} catch (e) {
if (e is MessageHandler) {
emit(state.copyWith(message: StateMessage.error(messageHandler: e)));
} else {
emit(
state.copyWith(
message: StateMessage.error(
messageHandler: ResponseMessage(
if (e is DioException) {
final error = NetworkException.getDioException(error: e);

if (error.message == NetworkError.NETWORK_ERROR_BAD_REQUEST) {
final data = error.data;

if (data != null &&
data is Map &&
data.containsKey('error') &&
data['error'] == 'invalid_grant') {
emitError(
ResponseMessage(
ResponseString.RESPONSE_STRING_userPinIsIncorrect,
),
);
} else {
emitError(
ResponseMessage(
ResponseString
.RESPONSE_STRING_SOMETHING_WENT_WRONG_TRY_AGAIN_LATER,
),
);
}
} else {
emitError(
ResponseMessage(
ResponseString
.RESPONSE_STRING_SOMETHING_WENT_WRONG_TRY_AGAIN_LATER,
),
);
}
} else if (e is MessageHandler) {
emit(state.copyWith(message: StateMessage.error(messageHandler: e)));
} else {
emitError(
ResponseMessage(
ResponseString.RESPONSE_STRING_SOMETHING_WENT_WRONG_TRY_AGAIN_LATER,
),
);
}
Expand Down
3 changes: 2 additions & 1 deletion lib/l10n/arb/app_en.arb
Original file line number Diff line number Diff line change
Expand Up @@ -947,5 +947,6 @@
"theCredentialIsNoMoreReady": "The ceredential is no more available.",
"lowSecurity": "Low Security",
"highSecurity": "High Security",
"theRequestIsRejected": "The request is rejected."
"theRequestIsRejected": "The request is rejected.",
"userPinIsIncorrect": "User pin is incorrect"
}
12 changes: 8 additions & 4 deletions lib/l10n/untranslated.json
Original file line number Diff line number Diff line change
Expand Up @@ -853,7 +853,8 @@
"theCredentialIsNoMoreReady",
"lowSecurity",
"highSecurity",
"theRequestIsRejected"
"theRequestIsRejected",
"userPinIsIncorrect"
],

"es": [
Expand Down Expand Up @@ -1710,7 +1711,8 @@
"theCredentialIsNoMoreReady",
"lowSecurity",
"highSecurity",
"theRequestIsRejected"
"theRequestIsRejected",
"userPinIsIncorrect"
],

"fr": [
Expand Down Expand Up @@ -1870,7 +1872,8 @@
"theCredentialIsNoMoreReady",
"lowSecurity",
"highSecurity",
"theRequestIsRejected"
"theRequestIsRejected",
"userPinIsIncorrect"
],

"it": [
Expand Down Expand Up @@ -2727,6 +2730,7 @@
"theCredentialIsNoMoreReady",
"lowSecurity",
"highSecurity",
"theRequestIsRejected"
"theRequestIsRejected",
"userPinIsIncorrect"
]
}
24 changes: 10 additions & 14 deletions packages/oidc4vc/lib/src/oidc4vc.dart
Original file line number Diff line number Diff line change
Expand Up @@ -709,21 +709,17 @@ class OIDC4VC {
String tokenEndPoint,
Map<String, dynamic> tokenData,
) async {
try {
/// getting token
final tokenHeaders = <String, dynamic>{
'Content-Type': 'application/x-www-form-urlencoded',
};
/// getting token
final tokenHeaders = <String, dynamic>{
'Content-Type': 'application/x-www-form-urlencoded',
};

final dynamic tokenResponse = await client.post<Map<String, dynamic>>(
tokenEndPoint,
options: Options(headers: tokenHeaders),
data: tokenData,
);
return tokenResponse.data;
} catch (e) {
throw Exception(e);
}
final dynamic tokenResponse = await client.post<Map<String, dynamic>>(
tokenEndPoint,
options: Options(headers: tokenHeaders),
data: tokenData,
);
return tokenResponse.data;
}

Future<void> sendPresentation({
Expand Down

0 comments on commit 58cdfde

Please sign in to comment.