mirror of
https://gitlab.com/PronounsPage/PronounsPage.git
synced 2025-09-22 12:03:25 -04:00
(refactor) use sha256 instead of md5 for the test version password
This commit is contained in:
parent
d0b884c527
commit
0c444ad1af
@ -1,6 +1,5 @@
|
||||
<script setup lang="ts">
|
||||
import sorter from 'avris-sorter';
|
||||
import md5 from 'js-md5';
|
||||
import { useCookie } from 'nuxt/app';
|
||||
|
||||
import useConfig from '~/composables/useConfig.ts';
|
||||
@ -8,11 +7,11 @@ import useDark from '~/composables/useDark.ts';
|
||||
import useDialogue from '~/composables/useDialogue.ts';
|
||||
import { longtimeCookieSetting } from '~/src/cookieSettings.ts';
|
||||
import { LoadScriptError } from '~/src/errors.ts';
|
||||
import { executeUnlessPrerendering } from '~/src/helpers.ts';
|
||||
import { executeUnlessPrerendering, sha256 } from '~/src/helpers.ts';
|
||||
import { useMainStore } from '~/store/index.ts';
|
||||
|
||||
// no need to be super secure, just a sign that the page is not public
|
||||
const TESTER_PASSWORD_HASH = '82feeb96d60170e714df8fb062301e90';
|
||||
const TESTER_PASSWORD_HASH = '3754c03824c4ea3b13e7b4b2d7ad35992dbf64f9ee680493fc7093bf176f49e5';
|
||||
|
||||
declare global {
|
||||
interface Window {
|
||||
@ -35,8 +34,12 @@ const requiresLogin = computed((): boolean => {
|
||||
return !config.macrolanguage?.enabled && (runtimeConfig.public.env === 'test' ||
|
||||
config.locale !== '_' && !locales[config.locale]?.published);
|
||||
});
|
||||
const testerPasswordValid = computed((): boolean => {
|
||||
return !!testerPasswordCookie.value && md5(testerPasswordCookie.value) === TESTER_PASSWORD_HASH;
|
||||
const testerPasswordValid = ref<boolean | undefined>();
|
||||
watchEffect(async () => {
|
||||
testerPasswordValid.value = undefined;
|
||||
if (testerPasswordCookie.value) {
|
||||
testerPasswordValid.value = await sha256(testerPasswordCookie.value) === TESTER_PASSWORD_HASH;
|
||||
}
|
||||
});
|
||||
const checkTesterPassword = (): void => {
|
||||
testerPasswordCookie.value = testerPassword.value;
|
||||
@ -123,7 +126,7 @@ const loadAds = async (): Promise<void> => {
|
||||
Sign in
|
||||
</button>
|
||||
</div>
|
||||
<p v-if="testerPasswordCookie && !testerPasswordValid" class="small text-danger">
|
||||
<p v-if="testerPasswordCookie && testerPasswordValid === false" class="small text-danger">
|
||||
<Icon v="exclamation-triangle" />
|
||||
Password invalid
|
||||
</p>
|
||||
|
Loading…
x
Reference in New Issue
Block a user