MCPcopy Index your code
hub / github.com/coderwhy/coderhub / verifyUser

Function verifyUser

src/middleware/user.middleware.js:5–23  ·  view source on GitHub ↗
(ctx, next)

Source from the content-addressed store, hash-verified

3const md5password = require('../utils/password-handle');
4
5const 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
25const handlePassword = async (ctx, next) => {
26 const { password } = ctx.request.body;

Callers

nothing calls this directly

Calls 1

getUserByNameMethod · 0.80

Tested by

no test coverage detected