Update users.js

if username not includes "@" or not an email, tools.normalizeAddress() function not working correctly.
This commit is contained in:
Mehmet Kozan 2023-03-28 15:49:21 +03:00
parent 8aee41f98a
commit b92ffe897f
No known key found for this signature in database
GPG key ID: 43A30106BC298926

View file

@ -583,12 +583,21 @@ module.exports = (db, server, userHandler, settingsHandler) => {
let userData;
try {
let unameview = ''
if(username.includes("@")){
unameview = tools.normalizeAddress(username, false, {
removeLabel: true,
removeDots: true
})
}
else{
unameview = username.replace(/\./g, '')
}
userData = await db.users.collection('users').findOne(
{
unameview: tools.normalizeAddress(username, false, {
removeLabel: true,
removeDots: true
})
unameview
},
{
projection: {