updating profile without version check

This commit is contained in:
Roland Osborne 2022-07-21 23:57:40 -07:00
parent fae657d356
commit f97a527eb8
3 changed files with 13 additions and 10 deletions

View File

@ -29,6 +29,7 @@ func SetAccountAuthentication(w http.ResponseWriter, r *http.Request) {
token.Account.Username = username;
token.Account.Handle = strings.ToLower(username);
token.Account.Password = password;
err := store.DB.Transaction(func(tx *gorm.DB) error {
if res := tx.Save(token.Account).Error; res != nil {
return res

View File

@ -1,6 +1,7 @@
package databag
import (
"strings"
"net/http"
"gorm.io/gorm"
"databag/internal/store"
@ -30,6 +31,9 @@ func SetAccountLogin(w http.ResponseWriter, r *http.Request) {
if res := tx.Model(&account).Update("Username", username).Error; res != nil {
return res
}
if res := tx.Model(&account).Update("Handle", strings.ToLower(username)).Error; res != nil {
return res
}
if res := tx.Model(&account).Update("Password", password).Error; res != nil {
return res
}

View File

@ -52,16 +52,14 @@ func SetCardProfile(w http.ResponseWriter, r *http.Request) {
return
}
if identity.Revision > card.ProfileRevision {
card.Username = identity.Handle
card.Name = identity.Name
card.Description = identity.Description
card.Location = identity.Location
card.Image = identity.Image
card.Version = identity.Version
card.Node = identity.Node
card.ProfileRevision = identity.Revision
}
card.Username = identity.Handle
card.Name = identity.Name
card.Description = identity.Description
card.Location = identity.Location
card.Image = identity.Image
card.Version = identity.Version
card.Node = identity.Node
card.ProfileRevision = identity.Revision
err = store.DB.Transaction(func(tx *gorm.DB) error {