|
@@ -1,16 +1,14 @@
|
|
|
'use strict';
|
|
|
-module.exports = ({ enable = false }) => {
|
|
|
+module.exports = () => {
|
|
|
return async function password(ctx, next) {
|
|
|
- if (enable) {
|
|
|
- // mongodb中secret转换为密码类型
|
|
|
- const method = ctx.request.method;
|
|
|
- const isLoginEnd = ctx.request.url.includes('login');
|
|
|
- const passwordNoDeal = ctx.request.headers.passwordnodeal;
|
|
|
- if (method !== 'GET' && !isLoginEnd && !passwordNoDeal) {
|
|
|
- const body = ctx.request.body;
|
|
|
- if (body && body.password) body.password = { secret: body.password };
|
|
|
- }
|
|
|
- await next();
|
|
|
- } else await next();
|
|
|
+ // mongodb中secret转换为密码类型
|
|
|
+ const method = ctx.request.method;
|
|
|
+ const isLoginEnd = ctx.request.url.includes('login');
|
|
|
+ const passwordNoDeal = ctx.request.headers.passwordnodeal;
|
|
|
+ if (method !== 'GET' && !isLoginEnd && !passwordNoDeal) {
|
|
|
+ const body = ctx.request.body;
|
|
|
+ if (body && body.password) body.password = { secret: body.password };
|
|
|
+ }
|
|
|
+ await next();
|
|
|
};
|
|
|
};
|