واجهة خلفية Development Tutorials, Guides & Insights
Unlock 1+ expert-curated واجهة خلفية tutorials, real-world code snippets, and modern dev strategies. From fundamentals to advanced topics, boost your واجهة خلفية skills on DeveloperBreeze.
Adblocker Detected
It looks like you're using an adblocker. Our website relies on ads to keep running. Please consider disabling your adblocker to support us and access the content.
Tutorial
javascript
بناء تطبيق ويب متقدم باستخدام React.js وNode.js
// Login user
router.post('/login', async (req, res) => {
const { email, password } = req.body;
try {
const user = await User.findOne({ email });
if (!user) return res.status(400).json({ message: 'المستخدم غير موجود' });
const isMatch = await bcrypt.compare(password, user.password);
if (!isMatch) return res.status(400).json({ message: 'كلمة المرور غير صحيحة' });
const token = jwt.sign({ id: user._id }, process.env.JWT_SECRET, { expiresIn: '1h' });
res.json({ token });
} catch (error) {
res.status(500).json({ message: 'خطأ في الدخول' });
}
}); cd backend
node server.jsSep 27, 2024
Read More