MCPcopy Create free account
hub / github.com/GoSimplicity/LinkMe / SignUp

Method SignUp

internal/api/user.go:60–84  ·  view source on GitHub ↗

SignUp 用户注册

(ctx *gin.Context)

Source from the content-addressed store, hash-verified

58
59// SignUp 用户注册
60func (uh *UserHandler) SignUp(ctx *gin.Context) {
61 var req req.SignUpReq
62 if err := ctx.ShouldBindJSON(&req); err != nil {
63 apiresponse.ErrorWithMessage(ctx, "无效的请求参数")
64 return
65 }
66
67 if req.Password != req.ConfirmPassword {
68 apiresponse.ErrorWithMessage(ctx, UserPasswordMismatchError)
69 return
70 }
71
72 // 尝试注册用户
73 err := uh.svc.SignUp(ctx.Request.Context(), domain.User{
74 Username: req.Username,
75 Password: req.Password,
76 })
77
78 if err != nil {
79 apiresponse.ErrorWithData(ctx, err)
80 return
81 }
82
83 apiresponse.Success(ctx)
84}
85
86// Login 用户登录
87func (uh *UserHandler) Login(ctx *gin.Context) {

Callers

nothing calls this directly

Calls 4

ErrorWithMessageFunction · 0.92
ErrorWithDataFunction · 0.92
SuccessFunction · 0.92
SignUpMethod · 0.65

Tested by

no test coverage detected