From f97a527eb815e3ef12c50e40b0b75398ad4fec77 Mon Sep 17 00:00:00 2001 From: Roland Osborne Date: Thu, 21 Jul 2022 23:57:40 -0700 Subject: [PATCH] updating profile without version check --- .../internal/api_setAccountAuthentication.go | 1 + net/server/internal/api_setAccountLogin.go | 4 ++++ net/server/internal/api_setCardProfile.go | 18 ++++++++---------- 3 files changed, 13 insertions(+), 10 deletions(-) diff --git a/net/server/internal/api_setAccountAuthentication.go b/net/server/internal/api_setAccountAuthentication.go index 91428025..68f7f4ea 100644 --- a/net/server/internal/api_setAccountAuthentication.go +++ b/net/server/internal/api_setAccountAuthentication.go @@ -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 diff --git a/net/server/internal/api_setAccountLogin.go b/net/server/internal/api_setAccountLogin.go index 37d2a2cb..fdad82f6 100644 --- a/net/server/internal/api_setAccountLogin.go +++ b/net/server/internal/api_setAccountLogin.go @@ -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 } diff --git a/net/server/internal/api_setCardProfile.go b/net/server/internal/api_setCardProfile.go index 6c2da9e4..88d304e7 100644 --- a/net/server/internal/api_setCardProfile.go +++ b/net/server/internal/api_setCardProfile.go @@ -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 {