hide phone number from public
This commit is contained in:
@@ -106,7 +106,11 @@ async function getAllUser(
|
||||
return and(...conditions);
|
||||
},
|
||||
});
|
||||
return users;
|
||||
|
||||
return users.map((u) => ({
|
||||
...u,
|
||||
phone: hidePhone(u.phone),
|
||||
}));
|
||||
}
|
||||
async function createUser(
|
||||
newUser: UserInsertSchema,
|
||||
@@ -210,3 +214,8 @@ function isValidThaiID(id: string) {
|
||||
const checkSum = (11 - (sum % 11)) % 10;
|
||||
return checkSum === Number(id[12]);
|
||||
}
|
||||
|
||||
function hidePhone(phone: string | null) {
|
||||
if (phone === null) return phone;
|
||||
return phone.slice(0, 2).concat("******").concat(phone.slice(-3));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user