Example #1
0
// ListAllUsers returns all the users
//
// GET /users
//
func (c *UsersController) ListAllUsers(ctx *gin.Context) {
	users, err := services.ListAllUsers()
	if err != nil {
		helpers.JSONResponseInternalServerError(ctx, err)
		return
	}
	helpers.JSONResponseCollection(ctx, presenters.UserCollectionPresenter(users))
}
Example #2
0
// ListOrganizations returns all available organizations
//
// GET /orgs
//
func (c *OrganizationsController) ListOrganizations(ctx *gin.Context) {
	orgs := []*schema.Organization{}

	//TODO: add pagination support via Skip and Limit query methods

	// err := models.Organization.Find(nil).All(&orgs)
	// if err != nil {
	// 	helpers.JSONResponseInternalServerError(ctx, err)
	// 	return
	// }

	helpers.JSONResponseCollection(ctx, presenters.OrganizationCollectionPresenter(orgs))
}
Example #3
0
// ListPublicMembers retusn the list of all public members. Each user can control the visibility of their membership. This will
// only includes the members that have chosen to do so.
//
// GET /orgs/:org/public_members
//
func (c *OrganizationsController) ListPublicMembers(ctx *gin.Context) {

	org := getOrganizationFromContext(ctx)
	orgService, err := services.NewOrganizationService(org, getCurrentUser(ctx))
	if err != nil {
		if c.WriteTrace {
			c.Logger.Printf("Failed to create OrganizationService for org: %v", org)
		}
		helpers.JSONResponseInternalServerError(ctx, err)
		return
	}

	members, err := orgService.GetPublicMembers()
	if err != nil {
		helpers.JSONResponseInternalServerError(ctx, err)
		return
	}

	helpers.JSONResponseCollection(ctx, presenters.MemberCollectionPresenter(members))
}