MCPcopy Create free account
hub / github.com/TalkingData/owl / createUser

Function createUser

api/users.go:126–156  ·  view source on GitHub ↗
(c *gin.Context)

Source from the content-addressed store, hash-verified

124}
125
126func createUser(c *gin.Context) {
127 response := gin.H{"code": http.StatusOK}
128 defer c.JSON(http.StatusOK, response)
129 var (
130 user *User
131 err error
132 )
133 if err = c.BindJSON(&user); err != nil {
134 response["code"] = http.StatusBadRequest
135 response["message"] = err.Error()
136 return
137 }
138 if user.Username == "" {
139 response["code"] = http.StatusBadRequest
140 response["message"] = "username is empty"
141 return
142 }
143 if user := mydb.getUserProfile(user.Username); user != nil {
144 response["code"] = http.StatusBadRequest
145 response["message"] = "user is exsits"
146 return
147 }
148 user.Password = utils.Md5(user.Username)
149 user.Type = LocalUser
150 if user, err = mydb.createUser(user); err != nil {
151 response["code"] = http.StatusInternalServerError
152 return
153 }
154 response["code"] = http.StatusOK
155 response["user"] = user
156}
157
158func deleteUser(c *gin.Context) {
159 response := gin.H{"code": http.StatusOK}

Callers

nothing calls this directly

Calls 2

getUserProfileMethod · 0.80
createUserMethod · 0.80

Tested by

no test coverage detected