multy-stub/server/routers/epja-2024-1/cats/auth/index.js
Primakov Alexandr Alexandrovich 4b0d9b4dbc mongoose + tests
2024-10-16 11:06:23 +03:00

17 lines
517 B
JavaScript

const authRouter = require('express').Router()
const { TOKEN } = require('../const')
module.exports = authRouter
authRouter.post('/login', (req, res) => {
const { email, password } = req.body
console.log(`Login with email=${email} and password=${password}`)
if (email === 'admin@admin.admin' && password === 'admin') {
res.status(200).send({ 'status': 'OK', 'data': `${TOKEN}` })
} else {
res.status(401).send({ 'status': 'Failed!', 'data': 'Invalid email or password' })
}
})