(ctx *gin.Context)
| 63 | } |
| 64 | |
| 65 | func (c *Core) handleUnbindUser(ctx *gin.Context) { |
| 66 | var params struct { |
| 67 | Nonce uint64 `json:"nonce"` |
| 68 | DeviceID string `json:"device"` |
| 69 | UserID string `json:"user"` |
| 70 | } |
| 71 | if err := c.bindBodyJSON(ctx, ¶ms); err != nil { |
| 72 | ctx.JSON(http.StatusBadRequest, gin.H{"res": http.StatusBadRequest, "msg": "unbind user device failed"}) |
| 73 | return |
| 74 | } |
| 75 | u, err := c.logic.GetUser(params.UserID) |
| 76 | if err == nil && !u.IsServerless() && !verifyUser(ctx, u.GetPublicKeyString()) { |
| 77 | ctx.JSON(http.StatusUnauthorized, gin.H{"res": http.StatusUnauthorized, "msg": "invalid user sign"}) |
| 78 | return |
| 79 | } |
| 80 | c.logic.UnbindDevice(params.UserID, params.DeviceID) // nolint: errcheck |
| 81 | ctx.JSON(http.StatusOK, gin.H{ |
| 82 | "uuid": params.DeviceID, |
| 83 | "uid": params.UserID, |
| 84 | }) |
| 85 | } |
nothing calls this directly
no test coverage detected