123456789101112 |
- 'use strict';
- const _ = require('lodash');
- module.exports = options => {
- return async function setuserfromtoken(ctx, next) {
- const token = _.get(ctx.request, 'header.token');
- if (token) {
- const data = ctx.service.util.jwt.decode(token);
- if (data) ctx.user = data;
- }
- await next();
- };
- };
|