diff --git a/storage/postgresql.go b/storage/postgresql.go index e59884a..5804e13 100644 --- a/storage/postgresql.go +++ b/storage/postgresql.go @@ -138,7 +138,10 @@ func (psql PostgresqlStorage) CreateAccount(account Account) error { } func (psql PostgresqlStorage) UpdateAccount(account Account) error { - updateAccountStmt := "update accounts set namespace=$1, data=$2, metadata=$3 where id= $4" + updateAccountStmt, err := psql.DbConnection.Prepare("update accounts set namespace=$1, data=$2, metadata=$3 where id= $4") + if err != nil { + return err + } dataAccountJson, err := json.Marshal(account.Data) if err != nil { return err @@ -147,11 +150,14 @@ func (psql PostgresqlStorage) UpdateAccount(account Account) error { if err != nil { return err } - _, err = psql.DbConnection.Exec(updateAccountStmt, account.Namespace, dataAccountJson, metadataAccountJson, account.ID) + _, err = updateAccountStmt.Exec(account.Namespace, dataAccountJson, metadataAccountJson, account.ID) + if err != nil { + return err + } + updateAccountAuthStmt, err := psql.DbConnection.Prepare("update account_auth set username = $1, password = $2, email = $3, email_validation = $4 ,phone_number = $5,phone_number_validation = $6 where account_id = $7") if err != nil { return err } - updateAccountAuthStmt := "update account_auth set username = $1, password = $2, email = $3, email_validation = $4 ,phone_number = $5,phone_number_validation = $6 where account_id = $7" emailValidationJson, err := json.Marshal(account.Authentication.Local.EmailValidation) if err != nil { return err @@ -160,7 +166,7 @@ func (psql PostgresqlStorage) UpdateAccount(account Account) error { if err != nil { return err } - _, err = psql.DbConnection.Exec(updateAccountAuthStmt, account.Authentication.Local.Username, account.Authentication.Local.Password, account.Authentication.Local.Email, + _, err = updateAccountAuthStmt.Exec(account.Authentication.Local.Username, account.Authentication.Local.Password, account.Authentication.Local.Email, emailValidationJson, account.Authentication.Local.PhoneNumber, phoneValidationJson, account.ID) if err != nil { return err