feat: add environment variable password protection and integrate it into the password gate component.

This commit is contained in:
kuekhaoyang
2025-12-21 21:18:07 +08:00
parent 156b9c56a1
commit 74e96fb1b5
3 changed files with 81 additions and 19 deletions
+17
View File
@@ -0,0 +1,17 @@
'use server';
/**
* Verifies if the provided password matches the ACCESS_PASSWORD environment variable.
*/
export async function verifyEnvPassword(password: string): Promise<boolean> {
const accessPassword = process.env.ACCESS_PASSWORD;
if (!accessPassword) return false;
return password === accessPassword;
}
/**
* Checks if a password is required by checking the presence of ACCESS_PASSWORD in the environment.
*/
export async function isEnvPasswordRequired(): Promise<boolean> {
return !!process.env.ACCESS_PASSWORD;
}