From e6d15f77e8fa4ec27e104297667b28dc5f8517ca Mon Sep 17 00:00:00 2001 From: enahum Date: Wed, 24 Aug 2016 18:10:49 -0300 Subject: PLT-3942 Add real-time updates for center channel profile picture popover (#3871) * PLT-3942 Add real-time updates for center channel profile picture pop-over * Send user data with the websocket event to prevent further requests * Add helper for profile sanitation --- model/user.go | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'model/user.go') diff --git a/model/user.go b/model/user.go index 3da862b6b..f857d5ef4 100644 --- a/model/user.go +++ b/model/user.go @@ -251,6 +251,22 @@ func (u *User) ClearNonProfileFields() { u.FailedAttempts = 0 } +func (u *User) SanitizeProfile(isSystemAdmin, pwdupdate, fullname, email bool) { + options := map[string]bool{} + options["passwordupdate"] = pwdupdate + + if isSystemAdmin { + options["fullname"] = true + options["email"] = true + } else { + options["fullname"] = fullname + options["email"] = email + u.ClearNonProfileFields() + } + + u.Sanitize(options) +} + func (u *User) MakeNonNil() { if u.Props == nil { u.Props = make(map[string]string) -- cgit v1.2.3-1-g7c22