mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01:38:19 +08:00
fix role manage
This commit is contained in:
1 parent
15d43636c0
commit
42e534615e
34 files changed
+221
-314
No files matched your search
+5
-28
@@ -3,6 +3,7 @@ const { ValidationError } = require('../error');
|
||||
const RE_UID = /^-?\d+$/i;
|
||||
const RE_PID = /^([a-zA-Z]+[a-zA-Z0-9]*)|$/i;
|
||||
const RE_UNAME = /[^\s\u3000](.{,254}[^\s\u3000])?$/i;
|
||||
const RE_ROLE = /^[_0-9A-Za-z]{1,256}$/i;
|
||||
const RE_MAIL = /^[a-zA-Z0-9_.+-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)+$/i;
|
||||
|
||||
const isTitle = (s) => s && s.length < 64;
|
||||
@@ -11,6 +12,8 @@ const isUid = (s) => RE_UID.test(s);
|
||||
const checkUid = (s) => { if (!isUid(s)) throw new ValidationError('uid'); else return s; };
|
||||
const isUname = (s) => RE_UNAME.test(s);
|
||||
const checkUname = (s) => { if (!isUname(s)) throw new ValidationError('uname'); else return s; };
|
||||
const isRole = (s) => RE_ROLE.test(s);
|
||||
const checkRole = (s) => { if (!isRole(s)) throw new ValidationError('role'); else return s; };
|
||||
const isPassword = (s) => s.length >= 5;
|
||||
const checkPassword = (s) => { if (!isPassword(s)) throw new ValidationError('password'); else return s; };
|
||||
const isEmail = (s) => RE_MAIL.test(s);
|
||||
@@ -33,6 +36,8 @@ module.exports = {
|
||||
checkUid,
|
||||
isUname,
|
||||
checkUname,
|
||||
isRole,
|
||||
checkRole,
|
||||
isPassword,
|
||||
checkPassword,
|
||||
isEmail,
|
||||
@@ -50,8 +55,6 @@ module.exports = {
|
||||
};
|
||||
/*
|
||||
ID_RE = re.compile(r'[^\\/\s\u3000]([^\\/\n\r]*[^\\/\s\u3000])?')
|
||||
ROLE_RE = re.compile(r'[_0-9A-Za-z]{1,256}')
|
||||
|
||||
|
||||
def is_id(s):
|
||||
return bool(ID_RE.fullmatch(s))
|
||||
@@ -67,14 +70,6 @@ def check_node_name(s):
|
||||
raise error.ValidationError('node_name')
|
||||
|
||||
|
||||
def is_role(s):
|
||||
return bool(ROLE_RE.fullmatch(s))
|
||||
|
||||
|
||||
def check_role(s):
|
||||
if not is_role(s):
|
||||
raise error.ValidationError('role')
|
||||
|
||||
def is_intro(s):
|
||||
return isinstance(s, str) and 0 < len(s.strip()) < 500
|
||||
|
||||
@@ -93,15 +88,6 @@ def check_description(s):
|
||||
raise error.ValidationError('description')
|
||||
|
||||
|
||||
def is_bulletin(s):
|
||||
return isinstance(s, str) and len(s) < 65536
|
||||
|
||||
|
||||
def check_bulletin(s):
|
||||
if not is_bulletin(s):
|
||||
raise error.ValidationError('bulletin')
|
||||
|
||||
|
||||
def is_lang(i):
|
||||
return i in constant.language.LANG_TEXTS
|
||||
|
||||
@@ -110,13 +96,4 @@ def check_lang(i):
|
||||
if not is_lang(i):
|
||||
raise error.ValidationError('lang')
|
||||
|
||||
|
||||
def is_domain_invitation_code(s):
|
||||
return bool(DOMAIN_INVITATION_CODE_RE.fullmatch(s))
|
||||
|
||||
|
||||
def check_domain_invitation_code(s):
|
||||
if not is_domain_invitation_code(s):
|
||||
raise error.ValidationError('invitation_code')
|
||||
|
||||
*/
|
||||
Reference in new issue
Block a user