Skip to content

Commit

Permalink
Added configuration for the number of qrCode auto refresh before show…
Browse files Browse the repository at this point in the history
…ing retry option
  • Loading branch information
YaswanthNagarjuna committed Aug 7, 2023
1 parent 0e935a2 commit 84726c3
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -237,4 +237,4 @@ mosip.esignet.ui.config.key-values={'sbi.env': 'Developer', 'sbi.timeout.DISC':
'linked-transaction-expire-in-secs': 120, 'wallet.qr-code-buffer-in-secs': 10, \
'mosip.esignet.qr-code.deep-link-uri': 'inji://landing-page-name?linkCode=LINK_CODE&linkExpireDateTime=LINK_EXPIRE_DT', \
'mosip.esignet.qr-code.download-uri': '#', 'mosip.esignet.qr-code.enable': 'true', 'auth.txnid.length': 10, \
'otp.length': 6, 'password.regex': ''}
'otp.length': 6, 'password.regex': '', 'wallet.qr-code.auto-refresh-limit': 3}
2 changes: 1 addition & 1 deletion oidc-ui/.env
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,4 @@ REACT_APP_WALLET_LOGO_URL=""

REACT_APP_CONSENT_SCREEN_TIME_OUT_BUFFER_IN_SEC=5

REACT_WALLET_QR_CODE_AUTO_REFRESH_LIMIT=10
REACT_WALLET_QR_CODE_AUTO_REFRESH_LIMIT=3
6 changes: 3 additions & 3 deletions oidc-ui/src/common/ErrorIndicator.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const ErrorIndicator = ({
const { t } = useTranslation("translation", { keyPrefix: i18nKeyPrefix });

//Redirecting if transaction invalid
if (errorCode === "invalid_transaction") {
if (errorCode === "invalid_transaction" || errorCode === "link_code_limit_reached") {
let response = location.hash;

if (!response) {
Expand All @@ -48,12 +48,12 @@ const ErrorIndicator = ({
if (nonce) {
params = params + "nonce=" + nonce + "&";
}
params = params + "error_description=" + t(errorCode, defaultMsg) + "&";
params = params + "error_description=" + t("invalid_transaction", defaultMsg) + "&";

//REQUIRED
params = params + "state=" + state + "&";
//REQUIRED
params = params + "error=" + errorCode;
params = params + "error=" + "invalid_transaction";

window.location.replace(redirect_uri + params);
return;
Expand Down
18 changes: 3 additions & 15 deletions oidc-ui/src/components/LoginQRCode.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,6 @@ export default function LoginQRCode({
configurationKeys.walletQrCodeAutoRefreshLimit
) ?? process.env.REACT_WALLET_QR_CODE_AUTO_REFRESH_LIMIT;

const maxUiRefreshes = 3;

const GenerateQRCode = (response, logoUrl) => {
let text =
openIDConnectService.getEsignetConfiguration(
Expand Down Expand Up @@ -129,23 +127,14 @@ export default function LoginQRCode({
};
}, []);

let fetchQrCodeCounter = 0;
let qrCodeRefreshCount = 0;

const fetchQRCode = async () => {
// If successfulFetchQrCount is 3, stop QR code generation and show QR code expired with a refresh button.
if (qrCodeRefreshCount >= walletQrCodeAutoRefreshLimit) {
// If fetchQRCode is triggered 10 times, show invalid transaction and redirect back to relying party UI.
setError({
errorCode: "invalid_transaction",
defaultMsg: "Invalid Transaction",
});
return;
}
if (fetchQrCodeCounter >= maxUiRefreshes) {
// If successfulFetchQrCount is 3, stop QR code generation and show QR code expired with a refresh button.
setError({
errorCode: "qr_code_expired",
defaultMsg: "QR code expired",
defaultMsg: "QR Code Expired",
});
return;
}
Expand Down Expand Up @@ -202,7 +191,7 @@ export default function LoginQRCode({
fetchQRCode();
}, timeLeftWithBuffer * 1000);
setQrCodeTimeout(_timer);
fetchQrCodeCounter++;
qrCodeRefreshCount++;
}
} catch (error) {
setError({
Expand All @@ -211,7 +200,6 @@ export default function LoginQRCode({
defaultMsg: error.message,
});
}
qrCodeRefreshCount++;
};

const triggerLinkStatus = async (
Expand Down

0 comments on commit 84726c3

Please sign in to comment.