(ctx, next)
| 3 | const md5password = require('../utils/password-handle'); |
| 4 | |
| 5 | const verifyUser = async (ctx, next) => { |
| 6 | // 1.获取用户名和密码 |
| 7 | const { name, password } = ctx.request.body; |
| 8 | |
| 9 | // 2.判断用户名或者密码不能空 |
| 10 | if (!name || !password) { |
| 11 | const error = new Error(errorTypes.NAME_OR_PASSWORD_IS_REQUIRED); |
| 12 | return ctx.app.emit('error', error, ctx); |
| 13 | } |
| 14 | |
| 15 | // 3.判断这次注册的用户名是没有被注册过 |
| 16 | const result = await service.getUserByName(name); |
| 17 | if (result.length) { |
| 18 | const error = new Error(errorTypes.USER_ALREADY_EXISTS); |
| 19 | return ctx.app.emit('error', error, ctx); |
| 20 | } |
| 21 | |
| 22 | await next(); |
| 23 | } |
| 24 | |
| 25 | const handlePassword = async (ctx, next) => { |
| 26 | const { password } = ctx.request.body; |
nothing calls this directly
no test coverage detected