(c *gin.Context)
| 212 | } |
| 213 | |
| 214 | func 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 | |
| 270 | func preRegisterProjectUser(c *gin.Context) { |
| 271 | r := struct { |
nothing calls this directly
no test coverage detected