MCPcopy Create free account
hub / github.com/chanify/chanify / handleUnbindUser

Method handleUnbindUser

core/user.go:65–85  ·  view source on GitHub ↗
(ctx *gin.Context)

Source from the content-addressed store, hash-verified

63}
64
65func (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, &params); 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}

Callers

nothing calls this directly

Calls 7

bindBodyJSONMethod · 0.95
verifyUserFunction · 0.85
IsServerlessMethod · 0.80
GetPublicKeyStringMethod · 0.80
JSONMethod · 0.65
GetUserMethod · 0.65
UnbindDeviceMethod · 0.65

Tested by

no test coverage detected