MCPcopy Index your code
hub / github.com/CovenantSQL/CovenantSQL / projectUserList

Function projectUserList

cmd/cql-proxy/api/project.go:214–268  ·  view source on GitHub ↗
(c *gin.Context)

Source from the content-addressed store, hash-verified

212}
213
214func projectUserList(c *gin.Context) {
215 r := struct {
216 DB proto.DatabaseID `json:"db" json:"project" form:"db" form:"project" uri:"db" uri:"project" binding:"required,len=64"`
217 Term string `json:"term" form:"term" binding:"max=32"`
218 ShowOnlyEnabled bool `json:"enabled" form:"enabled"`
219 Offset int64 `json:"offset" form:"offset" binding:"gte=0"`
220 Limit int64 `json:"limit" form:"limit" binding:"gte=0"`
221 }{}
222
223 _ = c.ShouldBindUri(&r)
224
225 if err := c.ShouldBind(&r); err != nil {
226 abortWithError(c, http.StatusBadRequest, err)
227 return
228 }
229
230 if r.Limit == 0 {
231 r.Limit = 20
232 }
233
234 _, projectDB, err := getProjectDB(c, r.DB)
235 if err != nil {
236 _ = c.Error(err)
237 abortWithError(c, http.StatusForbidden, ErrLoadProjectDatabaseFailed)
238 return
239 }
240
241 users, total, err := model.GetProjectUserList(projectDB, r.Term, r.ShowOnlyEnabled, r.Offset, r.Limit)
242 if err != nil {
243 _ = c.Error(err)
244 abortWithError(c, http.StatusInternalServerError, ErrGetUserListFailed)
245 return
246 }
247
248 var resp []gin.H
249
250 for _, u := range users {
251 resp = append(resp, gin.H{
252 "id": u.ID,
253 "name": u.Name,
254 "email": u.Email,
255 "state": u.State.String(),
256 "provider": u.Provider,
257 "provider_uid": u.ProviderUID,
258 "extra": u.Extra,
259 "created": formatUnixTime(u.Created),
260 "last_login": formatUnixTime(u.LastLogin),
261 })
262 }
263
264 responseWithData(c, http.StatusOK, gin.H{
265 "users": resp,
266 "total": total,
267 })
268}
269
270func preRegisterProjectUser(c *gin.Context) {
271 r := struct {

Callers

nothing calls this directly

Calls 7

GetProjectUserListFunction · 0.92
abortWithErrorFunction · 0.85
getProjectDBFunction · 0.85
formatUnixTimeFunction · 0.85
responseWithDataFunction · 0.85
ErrorMethod · 0.80
StringMethod · 0.45

Tested by

no test coverage detected