예제 #1
0
파일: user.go 프로젝트: saitodisse/platform
func getProfiles(c *Context, w http.ResponseWriter, r *http.Request) {

	etag := (<-Srv.Store.User().GetEtagForProfiles(c.Session.TeamId)).Data.(string)
	if HandleEtag(etag, w, r) {
		return
	}

	if result := <-Srv.Store.User().GetProfiles(c.Session.TeamId); result.Err != nil {
		c.Err = result.Err
		return
	} else {
		profiles := result.Data.(map[string]*model.User)

		for k, p := range profiles {
			options := utils.SanitizeOptions
			options["passwordupdate"] = false
			p.Sanitize(options)
			profiles[k] = p
		}

		w.Header().Set(model.HEADER_ETAG_SERVER, etag)
		w.Write([]byte(model.UserMapToJson(profiles)))
		return
	}
}
예제 #2
0
파일: admin.go 프로젝트: lfbrock/platform
func getRecentlyActiveUsers(c *Context, w http.ResponseWriter, r *http.Request) {
	statusMap := map[string]interface{}{}

	if result := <-Srv.Store.Status().GetAllFromTeam(c.TeamId); result.Err != nil {
		c.Err = result.Err
		return
	} else {
		statuses := result.Data.([]*model.Status)
		for _, s := range statuses {
			statusMap[s.UserId] = s.LastActivityAt
		}
	}

	if result := <-Srv.Store.User().GetProfiles(c.TeamId); result.Err != nil {
		c.Err = result.Err
		return
	} else {
		profiles := result.Data.(map[string]*model.User)

		for k, p := range profiles {
			p = sanitizeProfile(c, p)

			if lastActivityAt, ok := statusMap[p.Id].(int64); ok {
				p.LastActivityAt = lastActivityAt
			}

			profiles[k] = p
		}

		w.Write([]byte(model.UserMapToJson(profiles)))
	}

}
예제 #3
0
func getRecentlyActiveUsers(c *Context, w http.ResponseWriter, r *http.Request) {
	if result := <-Srv.Store.User().GetRecentlyActiveUsersForTeam(c.TeamId); result.Err != nil {
		c.Err = result.Err
		return
	} else {
		profiles := result.Data.(map[string]*model.User)

		for _, p := range profiles {
			sanitizeProfile(c, p)
		}

		w.Write([]byte(model.UserMapToJson(profiles)))
	}

}
예제 #4
0
파일: user.go 프로젝트: ftKnox/platform
func getProfiles(c *Context, w http.ResponseWriter, r *http.Request) {
	params := mux.Vars(r)
	id, ok := params["id"]
	if ok {
		// You must be system admin to access another team
		if id != c.Session.TeamId {
			if !c.HasSystemAdminPermissions("getProfiles") {
				return
			}
		}

	} else {
		id = c.Session.TeamId
	}

	etag := (<-Srv.Store.User().GetEtagForProfiles(id)).Data.(string)
	if HandleEtag(etag, w, r) {
		return
	}

	if result := <-Srv.Store.User().GetProfiles(id); result.Err != nil {
		c.Err = result.Err
		return
	} else {
		profiles := result.Data.(map[string]*model.User)

		for k, p := range profiles {
			options := utils.SanitizeOptions
			options["passwordupdate"] = false

			if c.IsSystemAdmin() {
				options["fullname"] = true
				options["email"] = true
			}

			p.Sanitize(options)
			p.ClearNonProfileFields()
			profiles[k] = p
		}

		w.Header().Set(model.HEADER_ETAG_SERVER, etag)
		w.Write([]byte(model.UserMapToJson(profiles)))
		return
	}
}