password.js 359 B

123456789101112
  1. 'use strict';
  2. module.exports = options => {
  3. return async function password(ctx, next) {
  4. // mongodb中secret转换为密码类型
  5. if (ctx.request.method !== 'GET' && !ctx.request.url.includes('login')) {
  6. const body = ctx.request.body;
  7. if (body && body.password) body.password = { secret: body.password };
  8. }
  9. await next();
  10. };
  11. };