MCPcopy Create free account
hub / github.com/badyun/AShare / post

Function post

controller/user.js:6–28  ·  view source on GitHub ↗
(req, res)

Source from the content-addressed store, hash-verified

4module.exports = {
5 login: {
6 async post(req, res) {
7 let userInfo = db('user').find({
8 username: req.body.username,
9 password: req.body.password
10 }).value()
11 if (userInfo) {
12 let token = jwt.createToken({ username: req.body.username, time: new Date() }, 3600 * 2)
13 let expireTime = new Date(new Date().getTime() + 3600 * 2 * 1000)
14 db('user')
15 .find({
16 username: req.body.username,
17 password: req.body.password
18 })
19 .assign({ expireTime: expireTime, token: token })
20 .write()
21 return res.return({
22 token: token,
23 role: userInfo.role
24 })
25 } else {
26 return res.error('账号或密码错误')
27 }
28 },
29 async get(req, res) {
30 return res.return(await registerClick())
31 }

Callers

nothing calls this directly

Calls 1

createTokenMethod · 0.80

Tested by

no test coverage detected