(c *gin.Context)
| 64 | } |
| 65 | |
| 66 | func 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 | |
| 88 | type FormLogout struct { |
| 89 | AuthToken string `form:"authToken" json:"authToken" binding:"required"` |
nothing calls this directly
no test coverage detected