diff options
Diffstat (limited to 'model/user.go')
-rw-r--r-- | model/user.go | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/model/user.go b/model/user.go index 8d8c76c68..7e767fd5c 100644 --- a/model/user.go +++ b/model/user.go @@ -88,6 +88,12 @@ type UserPatch struct { Locale *string `json:"locale"` } +type UserAuth struct { + Password string `json:"password,omitempty"` + AuthData *string `json:"auth_data,omitempty"` + AuthService string `json:"auth_service,omitempty"` +} + // IsValid validates the user and returns an error if it isn't configured // correctly. func (u *User) IsValid() *AppError { @@ -309,6 +315,15 @@ func (u *UserPatch) ToJson() string { } } +func (u *UserAuth) ToJson() string { + b, err := json.Marshal(u) + if err != nil { + return "" + } else { + return string(b) + } +} + // Generate a valid strong etag so the browser can cache the results func (u *User) Etag(showFullName, showEmail bool) string { return Etag(u.Id, u.UpdateAt, showFullName, showEmail) @@ -494,6 +509,17 @@ func UserPatchFromJson(data io.Reader) *UserPatch { } } +func UserAuthFromJson(data io.Reader) *UserAuth { + decoder := json.NewDecoder(data) + var user UserAuth + err := decoder.Decode(&user) + if err == nil { + return &user + } else { + return nil + } +} + func UserMapToJson(u map[string]*User) string { b, err := json.Marshal(u) if err != nil { |