core: user: update email normalization (#812)

This commit is contained in:
Yang Gao authored and GitHub committed 2024-05-18 21:04:59 +08:00
1 parent f38cf6e02a
commit 1a981b9bf5
2 files changed
+5 -8

No files matched your search

+2 -1
View File
@@ -177,7 +177,8 @@ export class User {
function handleMailLower(mail: string) {
const [n, d] = mail.trim().toLowerCase().split('@');
return `${n.replace(/\./g, '').replace(/\+.$/, '')}@${d === 'googlemail.com' ? 'gmail.com' : d}`;
const [name] = n.split('+');
return `${name.replace(/\./g, '')}@${d === 'googlemail.com' ? 'gmail.com' : d}`;
}
async function initAndCache(udoc: Udoc, dudoc, scope: bigint = PERM.PERM_ALL) {
+3 -7
View File
@@ -36,13 +36,9 @@ const langMap = {
Python3: 'py.py3',
};
function handleMailLower(mail: string) {
let data = mail.trim().toLowerCase();
if (data.endsWith('@googlemail.com')) data = data.replace('@googlemail.com', '@gmail.com');
if (data.endsWith('@gmail.com')) {
const [prev] = data.split('@');
data = `${prev.replace(/[.+]/g, '')}@gmail.com`;
}
return data;
const [n, d] = mail.trim().toLowerCase().split('@');
const [name] = n.split('+');
return `${name.replace(/\./g, '')}@${d === 'googlemail.com' ? 'gmail.com' : d}`;
}
export async function run({