MCPcopy Create free account
hub / github.com/coderwhy/coderhub / AuthController

Class AuthController

src/controller/auth.controller.js:4–18  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2const { PRIVATE_KEY } = require('../app/config');
3
4class 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
20module.exports = new AuthController();

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected