-
Notifications
You must be signed in to change notification settings - Fork 1
/
task3answer.js
31 lines (30 loc) · 882 Bytes
/
task3answer.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
const express = require('express')
const app = express()
app.all('/auth/login', (req, res) => {
res.append('Access-Control-Allow-Origin', '*')
res.append('Access-Control-Allow-Method', 'GET, POST, PUT, DELETE, HEAD')
if (!req.query.username || !req.query.password) {
res.status(400).json({
status: 'error',
msg: 'paramater error',
}).end()
} else if (req.query.username !== 'aaa') {
res.status(200).json({
status: 'error',
msg: 'user not exists',
}).end()
} else if (req.query.password !== '1234') {
res.status(200).json({
status: 'error',
msg: 'wrong password',
}).end()
} else {
res.status(200).json({
status: 'success',
msg: 'login success',
token: 'MzE1MzY3ZmQ3YjA1YTliNzk3YTFiMDhmNGQ0Y2RmYmEgIC0K',
}).end()
}
})
app.listen(9000)
console.log('server is running in port 9000')