From f1f40c0578c6d937a7e71cff89a9fa2c5d46b6b2 Mon Sep 17 00:00:00 2001 From: grassblock Date: Fri, 13 Jun 2025 10:43:01 +0800 Subject: [PATCH] feat: do not randomly generate a random number as password in case of locking out --- src/components/shortcodes/ProtectedContent.astro | 2 +- src/config.ts | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/components/shortcodes/ProtectedContent.astro b/src/components/shortcodes/ProtectedContent.astro index 5e05126..b6c384a 100644 --- a/src/components/shortcodes/ProtectedContent.astro +++ b/src/components/shortcodes/ProtectedContent.astro @@ -9,7 +9,7 @@ interface Props { const { password: propPassword, pwEnv } = Astro.props; // Get password from props, environment variable, or site config -const password = (pwEnv ? import.meta.env[pwEnv] : propPassword) || siteConfig.contentPassword || import.meta.env.CONTENT_PASSWORD || Math.random().toString(); +const password = (pwEnv ? import.meta.env[pwEnv] : propPassword) || siteConfig.contentPassword || import.meta.env.CONTENT_PASSWORD; // Get the slot content const content = await Astro.slots.render('default'); diff --git a/src/config.ts b/src/config.ts index 40171d0..0ca0a61 100644 --- a/src/config.ts +++ b/src/config.ts @@ -30,8 +30,9 @@ export const siteConfig = { displayAvatar: true, // display author avatar in the article list and info line of article page // encryption // the global password to encrypt/decrypt the content, if set, all without specifying a password will be encrypted with this password - // you can use a different environment variable to set the password. - contentPassword: import.meta.env.CONTENT_PASSWORD, + // To use an environment variable to set the password, replace the value with `import.meta.env.CONTENT_PASSWORD` + // (or process.env.CONTENT_PASSWORD, CONTENT_PASSWORD can be any string) and set the environment variable in your deployment service. + contentPassword: 'p1easeChangeMe!', // footer // yes you can write html safely here customFooter: 'I have no mouth, and I must SCREAM',