| 2 | const { PRIVATE_KEY } = require('../app/config'); |
| 3 | |
| 4 | class AuthController { |
| 5 | async login(ctx, next) { |
| 6 | const { id, name } = ctx.user; |
| 7 | const token = jwt.sign({ id, name }, PRIVATE_KEY, { |
| 8 | expiresIn: 60 * 60 * 24, |
| 9 | algorithm: 'RS256' |
| 10 | }); |
| 11 | |
| 12 | ctx.body = { id, name, token } |
| 13 | } |
| 14 | |
| 15 | async success(ctx, next) { |
| 16 | ctx.body = "授权成功~"; |
| 17 | } |
| 18 | } |
| 19 | |
| 20 | module.exports = new AuthController(); |
nothing calls this directly
no outgoing calls
no test coverage detected