MCPcopy Create free account
hub / github.com/LockGit/gochat / Login

Function Login

api/handler/user.go:21–37  ·  view source on GitHub ↗
(c *gin.Context)

Source from the content-addressed store, hash-verified

19}
20
21func Login(c *gin.Context) {
22 var formLogin FormLogin
23 if err := c.ShouldBindBodyWith(&formLogin, binding.JSON); err != nil {
24 tools.FailWithMsg(c, err.Error())
25 return
26 }
27 req := &proto.LoginRequest{
28 Name: formLogin.UserName,
29 Password: tools.Sha1(formLogin.Password),
30 }
31 code, authToken, msg := rpc.RpcLogicObj.Login(req)
32 if code == tools.CodeFail || authToken == "" {
33 tools.FailWithMsg(c, msg)
34 return
35 }
36 tools.SuccessWithMsg(c, "login success", authToken)
37}
38
39type FormRegister struct {
40 UserName string `form:"userName" json:"userName" binding:"required"`

Callers

nothing calls this directly

Calls 4

FailWithMsgFunction · 0.92
Sha1Function · 0.92
SuccessWithMsgFunction · 0.92
LoginMethod · 0.45

Tested by

no test coverage detected