added pin hash compatibility.

This commit is contained in:
shumit taher 2025-09-30 05:07:04 +00:00
parent 851badc496
commit 7352fd23a8
5 changed files with 15 additions and 7 deletions

View file

@ -243,7 +243,7 @@ For more info, see the **[Authentication Docs](/docs/authentication.md)**
**`items`** | `array` | _Optional_ | An array of items to be displayed within the section. See [`item`](#sectionitem). Sections must include either 1 or more items, or 1 or more widgets.
**`widgets`** | `array` | _Optional_ | An array of widgets to be displayed within the section. See [`widget`](#sectionwidget-optional)
**`displayData`** | `object` | _Optional_ | Meta-data to optionally override display settings for a given section. See [`displayData`](#sectiondisplaydata-optional)
**`pin`** | `string` | _Optional_ | The PIN code for unlocking this section if `secret` under `displayData` is true. Provide at the section root (e.g., pin: 2749). Validated client-side and remembered only for the current browser tab/session. Not intended for protecting highly sensitive data. Only for Child-proofing. if not entered but section is locked then default pin will be 0000
**`pin`** | `string` | _Optional_ | The PIN code for unlocking this section if `secret` under `displayData` is true. Provide at the section root (e.g., pin: 2749). Validated client-side and remembered only for the current browser tab/session. Not intended for protecting highly sensitive data. Only for Child-proofing. if not entered but section is locked then default pin will be 0000. optionally user can input SHA256 hash of their pin here.
**[⬆️ Back to Top](#configuring)**

View file

@ -126,6 +126,7 @@ import ContextMenu from '@/components/LinkItems/SectionContextMenu.vue';
import PinInput from '@/components/InteractiveEditor/PinInput.vue';
import ErrorHandler from '@/utils/ErrorHandler';
import StoreKeys from '@/utils/StoreMutations';
import { pinHash } from '@/utils/SectionHelpers';
import {
sortOrder as defaultSortOrder,
localStorageKeys,
@ -141,7 +142,7 @@ export default {
groupId: String,
title: String,
icon: String,
pin: String,
pin: [String, Number],
displayData: Object,
items: Array,
widgets: Array,
@ -337,7 +338,9 @@ export default {
sessionStorage.setItem(SECRET_UNLOCKED_KEY, JSON.stringify(map));
const unlockPins = JSON.parse(sessionStorage.getItem(SECRET_UNLOCKED_KEY) || '{}');
const sectionKey = this.sectionRef;
if (unlockPins[sectionKey] === this.pin) {
const savedPin = unlockPins[sectionKey];
if (savedPin === pinHash(pin) || savedPin === pin.toString()) {
this.pinError = '';
this.isUnlocked = true;
} else {

View file

@ -758,7 +758,7 @@
},
"pin":{
"title": "Section Pin",
"type": "string",
"type": ["number", "string"],
"description": "PIN to unlock this section"
},
"displayData": {

View file

@ -1,5 +1,5 @@
/* Helper functions for Sections and Items */
import sha256 from 'crypto-js/sha256';
import { hideFurnitureOn } from '@/utils/defaults';
/* Returns false if page furniture should be hidden on said route */
@ -39,3 +39,8 @@ export const applyItemId = (inputSections) => {
});
return sections;
};
export const pinHash = (pin) => {
if (!pin) return null;
return sha256(pin).toString().toUpperCase();
};

View file

@ -46,7 +46,7 @@ sections:
icon: far fa-hands-helping
- name: Stuff
icon: fas fa-rocket
pin: "1112"
pin: FE91A760983D401D9B679FB092B689488D1F46D92F3AF5E9E93363326F3E8AA4
displayData:
secret: true
items:
@ -62,7 +62,7 @@ sections:
target: newtab
- name: Stuff 2
icon: fas fa-rocket
pin: "1114"
pin: 1114
displayData:
secret: true
items: