26 lines
875 B
JavaScript
26 lines
875 B
JavaScript
export function getUserSafetyFilter(context) {
|
|
const application = context.getApplication();
|
|
const { config } = application.system;
|
|
const { Security } = config || {};
|
|
if (Security && ['strong', 'medium'].includes(Security.level)) {
|
|
// 对于安全要求中高的系统,需要检查其验证密码时间
|
|
const stamp = Date.now() - Security.passwordVerifyGap;
|
|
return {
|
|
$or: [
|
|
{
|
|
verifyPasswordAt: {
|
|
$gte: stamp,
|
|
},
|
|
},
|
|
{
|
|
hasPassword: false,
|
|
}
|
|
]
|
|
};
|
|
}
|
|
}
|
|
export function maskPassword(password) {
|
|
const encStr = "****************************************".slice(0, password.length - 2);
|
|
return password[0] + encStr + password[password.length - 1];
|
|
}
|