mirror of
https://github.com/ragestudio/comty.git
synced 2025-06-09 10:34:17 +00:00
37 lines
980 B
JavaScript
Executable File
37 lines
980 B
JavaScript
Executable File
import { User } from "@shared-classes/DbModels"
|
|
|
|
export default {
|
|
method: "GET",
|
|
route: "/login/validation",
|
|
fn: async function (req, res) {
|
|
// just check if the provided user or/and email exists, if is return false, otherwise return true
|
|
const { username, email } = req.query
|
|
|
|
if (!username && !email) {
|
|
return res.status(400).json({
|
|
message: "Missing username or email",
|
|
})
|
|
}
|
|
|
|
const user = await User.findOne({
|
|
$or: [
|
|
{ username: username },
|
|
{ email: email },
|
|
]
|
|
}).catch((error) => {
|
|
return false
|
|
})
|
|
|
|
if (user) {
|
|
return res.json({
|
|
message: "User already exists",
|
|
exists: true,
|
|
})
|
|
} else {
|
|
return res.json({
|
|
message: "User doesn't exists",
|
|
exists: false,
|
|
})
|
|
}
|
|
}
|
|
} |