Skip to content

Commit

Permalink
Merge pull request #299 from YaswanthNagarjuna/ES-206
Browse files Browse the repository at this point in the history
[ES-206] Added configuration for the number of qrCode auto refresh before showing retry option.
  • Loading branch information
gsasikumar authored Aug 9, 2023
2 parents 3de6439 + 84726c3 commit ace7e61
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 6 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}
4 changes: 3 additions & 1 deletion oidc-ui/.env
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,6 @@ REACT_APP_PASSWORD_REGEX=""

REACT_APP_WALLET_LOGO_URL=""

REACT_APP_CONSENT_SCREEN_TIME_OUT_BUFFER_IN_SEC=5
REACT_APP_CONSENT_SCREEN_TIME_OUT_BUFFER_IN_SEC=5

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
15 changes: 15 additions & 0 deletions oidc-ui/src/components/LoginQRCode.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ export default function LoginQRCode({
configurationKeys.walletLogoURL
) ?? process.env.REACT_APP_WALLET_LOGO_URL;

const walletQrCodeAutoRefreshLimit = openIDConnectService.getEsignetConfiguration(
configurationKeys.walletQrCodeAutoRefreshLimit
) ?? process.env.REACT_WALLET_QR_CODE_AUTO_REFRESH_LIMIT;

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

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) {
setError({
errorCode: "qr_code_expired",
defaultMsg: "QR Code Expired",
});
return;
}
setQr("");
setError(null);
try {
Expand Down Expand Up @@ -177,6 +191,7 @@ export default function LoginQRCode({
fetchQRCode();
}, timeLeftWithBuffer * 1000);
setQrCodeTimeout(_timer);
qrCodeRefreshCount++;
}
} catch (error) {
setError({
Expand Down
3 changes: 2 additions & 1 deletion oidc-ui/src/constants/clientConstants.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,8 @@ const configurationKeys = {
passwordRegex : "password.regex",
walletLogoURL: "wallet.logo-url",
consentScreenExpireInSec: "consent.screen.timeout-in-secs",
consentScreenTimeOutBufferInSec: "consent.screen.timeout-buffer-in-secs"
consentScreenTimeOutBufferInSec: "consent.screen.timeout-buffer-in-secs",
walletQrCodeAutoRefreshLimit: "wallet.qr-code.auto-refresh-limit"
};

export {
Expand Down

0 comments on commit ace7e61

Please sign in to comment.