mirror of
https://github.com/rikkaneko/paste.git
synced 2025-08-03 12:40:07 +01:00
Update password rules and error message
Signed-off-by: Joe Ma <rikkaneko23@gmail.com>
This commit is contained in:
parent
8704a9161e
commit
d2a1dd13b8
2 changed files with 4 additions and 7 deletions
|
@ -191,12 +191,9 @@ router.post('/', async (request, env, ctx) => {
|
||||||
|
|
||||||
// Check password rules
|
// Check password rules
|
||||||
if (password && !check_password_rules(password)) {
|
if (password && !check_password_rules(password)) {
|
||||||
return new Response(
|
return new Response('Password can only contain alphabets and digits only.', {
|
||||||
'Invalid password. ' + 'Password must contain alphabets and digits only, and has a length of 4 or more.',
|
status: 422,
|
||||||
{
|
});
|
||||||
status: 422,
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check request.body size <= 25MB
|
// Check request.body size <= 25MB
|
||||||
|
|
|
@ -141,7 +141,7 @@ export async function get_paste_info(
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
export function check_password_rules(password: string): boolean {
|
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
|
// Extract username and password from Basic Authorization header
|
||||||
export function get_basic_auth(headers: Headers): [string, string] | null {
|
export function get_basic_auth(headers: Headers): [string, string] | null {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue