mirror of
https://github.com/Lissy93/dashy.git
synced 2025-12-06 16:43:13 +01:00
✨ added pin hash compatibility.
This commit is contained in:
parent
851badc496
commit
7352fd23a8
5 changed files with 15 additions and 7 deletions
|
|
@ -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.
|
**`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)
|
**`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)
|
**`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)**
|
**[⬆️ Back to Top](#configuring)**
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -126,6 +126,7 @@ import ContextMenu from '@/components/LinkItems/SectionContextMenu.vue';
|
||||||
import PinInput from '@/components/InteractiveEditor/PinInput.vue';
|
import PinInput from '@/components/InteractiveEditor/PinInput.vue';
|
||||||
import ErrorHandler from '@/utils/ErrorHandler';
|
import ErrorHandler from '@/utils/ErrorHandler';
|
||||||
import StoreKeys from '@/utils/StoreMutations';
|
import StoreKeys from '@/utils/StoreMutations';
|
||||||
|
import { pinHash } from '@/utils/SectionHelpers';
|
||||||
import {
|
import {
|
||||||
sortOrder as defaultSortOrder,
|
sortOrder as defaultSortOrder,
|
||||||
localStorageKeys,
|
localStorageKeys,
|
||||||
|
|
@ -141,7 +142,7 @@ export default {
|
||||||
groupId: String,
|
groupId: String,
|
||||||
title: String,
|
title: String,
|
||||||
icon: String,
|
icon: String,
|
||||||
pin: String,
|
pin: [String, Number],
|
||||||
displayData: Object,
|
displayData: Object,
|
||||||
items: Array,
|
items: Array,
|
||||||
widgets: Array,
|
widgets: Array,
|
||||||
|
|
@ -337,7 +338,9 @@ export default {
|
||||||
sessionStorage.setItem(SECRET_UNLOCKED_KEY, JSON.stringify(map));
|
sessionStorage.setItem(SECRET_UNLOCKED_KEY, JSON.stringify(map));
|
||||||
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) {
|
const savedPin = unlockPins[sectionKey];
|
||||||
|
|
||||||
|
if (savedPin === pinHash(pin) || savedPin === pin.toString()) {
|
||||||
this.pinError = '';
|
this.pinError = '';
|
||||||
this.isUnlocked = true;
|
this.isUnlocked = true;
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
|
|
@ -758,7 +758,7 @@
|
||||||
},
|
},
|
||||||
"pin":{
|
"pin":{
|
||||||
"title": "Section Pin",
|
"title": "Section Pin",
|
||||||
"type": "string",
|
"type": ["number", "string"],
|
||||||
"description": "PIN to unlock this section"
|
"description": "PIN to unlock this section"
|
||||||
},
|
},
|
||||||
"displayData": {
|
"displayData": {
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/* Helper functions for Sections and Items */
|
/* Helper functions for Sections and Items */
|
||||||
|
import sha256 from 'crypto-js/sha256';
|
||||||
import { hideFurnitureOn } from '@/utils/defaults';
|
import { hideFurnitureOn } from '@/utils/defaults';
|
||||||
|
|
||||||
/* Returns false if page furniture should be hidden on said route */
|
/* Returns false if page furniture should be hidden on said route */
|
||||||
|
|
@ -39,3 +39,8 @@ export const applyItemId = (inputSections) => {
|
||||||
});
|
});
|
||||||
return sections;
|
return sections;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const pinHash = (pin) => {
|
||||||
|
if (!pin) return null;
|
||||||
|
return sha256(pin).toString().toUpperCase();
|
||||||
|
};
|
||||||
|
|
|
||||||
|
|
@ -46,7 +46,7 @@ sections:
|
||||||
icon: far fa-hands-helping
|
icon: far fa-hands-helping
|
||||||
- name: Stuff
|
- name: Stuff
|
||||||
icon: fas fa-rocket
|
icon: fas fa-rocket
|
||||||
pin: "1112"
|
pin: FE91A760983D401D9B679FB092B689488D1F46D92F3AF5E9E93363326F3E8AA4
|
||||||
displayData:
|
displayData:
|
||||||
secret: true
|
secret: true
|
||||||
items:
|
items:
|
||||||
|
|
@ -62,7 +62,7 @@ sections:
|
||||||
target: newtab
|
target: newtab
|
||||||
- name: Stuff 2
|
- name: Stuff 2
|
||||||
icon: fas fa-rocket
|
icon: fas fa-rocket
|
||||||
pin: "1114"
|
pin: 1114
|
||||||
displayData:
|
displayData:
|
||||||
secret: true
|
secret: true
|
||||||
items:
|
items:
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue