Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 1 addition & 5 deletions models/account.go
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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
Expand Down
20 changes: 11 additions & 9 deletions routes/accounts.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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 != "" {
Expand Down