123456789101112131415161718 |
- 'use strict';
- const { CrudService } = require('naf-framework-mongoose-free/lib/service');
- const jwt = require('jsonwebtoken');
- // jsonWebToken处理
- class JwtService extends CrudService {
- constructor(ctx) {
- super(ctx, 'jwt');
- }
- encrypt(data) {
- const { secret } = this.config.jwt;
- const token = jwt.sign(data, secret);
- return token;
- }
- }
- module.exports = JwtService;
|