user.js 729 B

1234567891011121314151617181920212223242526272829303132333435
  1. const config = require('../src/utils/config')
  2. const { apiPrefix } = config
  3. const adminUsers = [
  4. {
  5. id: 1,
  6. username: 'admin',
  7. password: 'admin'
  8. }, {
  9. id: 2,
  10. username: 'guest',
  11. password: 'guest'
  12. }
  13. ]
  14. module.exports = {
  15. /*[`POST ${apiPrefix}/user/login`] (req, res) {
  16. const { username, password } = req.body
  17. const user = adminUsers.filter(item => item.username === username)
  18. if (user.length > 0 && user[0].password === password) {
  19. res.json({ success: true, message: 'Ok',user:user[0] })
  20. } else {
  21. res.status(400).end()
  22. }
  23. },*/
  24. [`GET ${apiPrefix}/logout`] (req, res) {
  25. res.clearCookie('token')
  26. res.status(200).end()
  27. }
  28. }