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

Function CheckAuth

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

Source from the content-addressed store, hash-verified

64}
65
66func CheckAuth(c *gin.Context) {
67 var formCheckAuth FormCheckAuth
68 if err := c.ShouldBindBodyWith(&formCheckAuth, binding.JSON); err != nil {
69 tools.FailWithMsg(c, err.Error())
70 return
71 }
72 authToken := formCheckAuth.AuthToken
73 req := &proto.CheckAuthRequest{
74 AuthToken: authToken,
75 }
76 code, userId, userName := rpc.RpcLogicObj.CheckAuth(req)
77 if code == tools.CodeFail {
78 tools.FailWithMsg(c, "auth fail")
79 return
80 }
81 var jsonData = map[string]interface{}{
82 "userId": userId,
83 "userName": userName,
84 }
85 tools.SuccessWithMsg(c, "auth success", jsonData)
86}
87
88type FormLogout struct {
89 AuthToken string `form:"authToken" json:"authToken" binding:"required"`

Callers

nothing calls this directly

Calls 3

FailWithMsgFunction · 0.92
SuccessWithMsgFunction · 0.92
CheckAuthMethod · 0.45

Tested by

no test coverage detected