diff --git a/models/account.go b/models/account.go index bcb1ae5..6159ae0 100644 --- a/models/account.go +++ b/models/account.go @@ -22,8 +22,7 @@ type Account struct { PGPKey string `json:"pgp_key" gorethink:"pgp_key"` // Settings contains data needed to customize the user experience. - // TODO Work in progress - Settings SettingsData `json:"settings" gorethink:"settings"` + Settings interface{} `json:"settings" gorethink:"settings"` // Type is the account type. // Examples (work in progress): @@ -39,9 +38,6 @@ type Account struct { FactorValue []string `json:"-" gorethink:"factor_value"` Status string `json:"status" gorethink:"status"` - - // AppData is used for clientside settings storage - AppData interface{} `json:"app_data" gorethink:"app_data"` } // SetPassword changes the account's password diff --git a/routes/accounts.go b/routes/accounts.go index 621c595..7a59802 100644 --- a/routes/accounts.go +++ b/routes/accounts.go @@ -381,7 +381,7 @@ type AccountsUpdateRequest struct { FactorType string `json:"factor_type" schema:"factor_type"` FactorValue []string `json:"factor_value" schema:"factor_value"` Token string `json:"token" schema:"token"` - AppData interface{} `json:"app_data" schema:"app_data"` + Settings interface{} `json:"settings" schema:"settings"` } // AccountsUpdateResponse contains the result of the AccountsUpdate request. @@ -435,12 +435,14 @@ func AccountsUpdate(c web.C, w http.ResponseWriter, r *http.Request) { return } - if valid, _, err := user.VerifyPassword(input.CurrentPassword); err != nil || !valid { - utils.JSONResponse(w, 403, &AccountsUpdateResponse{ - Success: false, - Message: "Invalid current password", - }) - return + if input.NewPassword != "" { + if valid, _, err := user.VerifyPassword(input.CurrentPassword); err != nil || !valid { + utils.JSONResponse(w, 403, &AccountsUpdateResponse{ + Success: false, + Message: "Invalid current password", + }) + return + } } // Check for 2nd factor @@ -512,8 +514,8 @@ func AccountsUpdate(c web.C, w http.ResponseWriter, r *http.Request) { user.AltEmail = input.AltEmail } - if input.AppData != nil { - user.AppData = input.AppData + if input.Settings != nil { + user.Settings = input.Settings } if input.FactorType != "" {