Update password rules and error message

Signed-off-by: Joe Ma <rikkaneko23@gmail.com>
This commit is contained in:
Joe Ma 2024-02-05 12:40:53 +08:00
parent 8704a9161e
commit d2a1dd13b8
No known key found for this signature in database
GPG key ID: 7A0ECF5F5EDC587F
2 changed files with 4 additions and 7 deletions

View file

@ -191,12 +191,9 @@ router.post('/', async (request, env, ctx) => {
// Check password rules
if (password && !check_password_rules(password)) {
return new Response(
'Invalid password. ' + 'Password must contain alphabets and digits only, and has a length of 4 or more.',
{
status: 422,
}
);
return new Response('Password can only contain alphabets and digits only.', {
status: 422,
});
}
// Check request.body size <= 25MB

View file

@ -141,7 +141,7 @@ export async function get_paste_info(
});
}
export function check_password_rules(password: string): boolean {
return password.match('^[A-z0-9]{4,}$') !== null;
return password.match('^[A-z0-9]{1,}$') !== null;
}
// Extract username and password from Basic Authorization header
export function get_basic_auth(headers: Headers): [string, string] | null {