error message added in case of wrong pin

This commit is contained in:
shumit taher 2025-09-29 11:18:27 +00:00
parent bcfb7cbbaf
commit 21b09952cb
4 changed files with 14 additions and 4 deletions

View file

@ -255,7 +255,8 @@
"unlock": "Unlock", "unlock": "Unlock",
"lock": "Lock", "lock": "Lock",
"lockedSection": "Locked section", "lockedSection": "Locked section",
"enter-pin": "Enter PIN" "enter-pin": "Enter PIN",
"incorrect-pin": "Incorrect PIN"
}, },
"footer": { "footer": {
"dev-by": "Developed by", "dev-by": "Developed by",

View file

@ -13,11 +13,13 @@
/> />
<div class="pin-actions"> <div class="pin-actions">
<div v-if="errorMessage" class="pin-error">{{ errorMessage }}</div>
<button class="pin-btn" @click="submit" :aria-label="$t('pin.unlock')"> <button class="pin-btn" @click="submit" :aria-label="$t('pin.unlock')">
<i class="fas fa-unlock-alt btn-icon" aria-hidden="true"></i> <i class="fas fa-unlock-alt btn-icon" aria-hidden="true"></i>
{{ $t('pin.unlock') }} {{ $t('pin.unlock') }}
</button> </button>
</div> </div>
</div> </div>
</template> </template>
@ -29,6 +31,7 @@ export default {
components: { FormSchema }, components: { FormSchema },
props: { props: {
id: String, id: String,
errorMessage: String,
}, },
data() { data() {
return { return {

View file

@ -17,6 +17,7 @@
<PinInput <PinInput
v-if="showPinRequired" v-if="showPinRequired"
:id = "sectionRef" :id = "sectionRef"
:errorMessage="pinError"
@unlock_attempt="saveUnlockPins" @unlock_attempt="saveUnlockPins"
/> />
<div v-if="!showPinRequired"> <div v-if="!showPinRequired">
@ -168,6 +169,7 @@ export default {
sectionWidth: 0, sectionWidth: 0,
resizeObserver: null, resizeObserver: null,
isUnlocked: true, isUnlocked: true,
pinError: '',
}; };
}, },
computed: { computed: {
@ -378,14 +380,13 @@ export default {
const map = JSON.parse(sessionStorage.getItem(SECRET_UNLOCKED_KEY) || '{}'); const map = JSON.parse(sessionStorage.getItem(SECRET_UNLOCKED_KEY) || '{}');
map[id] = pin; map[id] = pin;
sessionStorage.setItem(SECRET_UNLOCKED_KEY, JSON.stringify(map)); sessionStorage.setItem(SECRET_UNLOCKED_KEY, JSON.stringify(map));
this.updateUnlocked();
},
updateUnlocked() {
const unlockPins = JSON.parse(sessionStorage.getItem(SECRET_UNLOCKED_KEY) || '{}'); const unlockPins = JSON.parse(sessionStorage.getItem(SECRET_UNLOCKED_KEY) || '{}');
const sectionKey = this.sectionRef; const sectionKey = this.sectionRef;
if (unlockPins[sectionKey] === this.pin) { if (unlockPins[sectionKey] === this.pin) {
this.pinError = '';
this.isUnlocked = true; this.isUnlocked = true;
} else { } else {
this.pinError = this.$t('pin.incorrect-pin');
this.isUnlocked = false; this.isUnlocked = false;
} }
}, },
@ -396,6 +397,7 @@ export default {
delete unlockPins[sectionKey]; delete unlockPins[sectionKey];
sessionStorage.setItem(SECRET_UNLOCKED_KEY, JSON.stringify(unlockPins)); sessionStorage.setItem(SECRET_UNLOCKED_KEY, JSON.stringify(unlockPins));
} }
this.pinError = '';
this.isUnlocked = false; this.isUnlocked = false;
}, },
}, },

View file

@ -63,3 +63,7 @@
width: 100%; width: 100%;
justify-content: flex-end; justify-content: flex-end;
} }
.pin-error {
color: var(--error, #d9534f);
}