Spaces:
Paused
Paused
Download Controller/findUser.js from imkrish/campverse-backend: direct link, hf CLI and curl.
- Browser
- Download file 661 Bytes
-
https://huggingface.co/spaces/imkrish/campverse-backend/resolve/main/Controller/findUser.js
- Command line
-
hf download hf://spaces/imkrish/campverse-backend/Controller/findUser.js
-
curl -L -o findUser.js https://huggingface.co/spaces/imkrish/campverse-backend/resolve/main/Controller/findUser.js
661 Bytes
| const User = require('../Models/User'); | |
| async function findUserByEmail(req, res) { | |
| try { | |
| const { email } = req.query; | |
| if (!email) { | |
| return res.status(400).json({ error: 'Email query parameter is required.' }); | |
| } | |
| const normalizedEmail = String(email).toLowerCase().trim(); | |
| const user = await User.findOne({ email: normalizedEmail }).select('_id name email canHost profilePhoto'); | |
| if (!user) { | |
| return res.status(404).json({ error: 'User not found.' }); | |
| } | |
| res.json({ success: true, user }); | |
| } catch (err) { | |
| res.status(500).json({ error: 'Error finding user.' }); | |
| } | |
| } | |
| module.exports = { findUserByEmail }; | |