[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[taler-taldir] branch master updated: fix
From: |
gnunet |
Subject: |
[taler-taldir] branch master updated: fix |
Date: |
Tue, 12 Jul 2022 15:36:28 +0200 |
This is an automated email from the git hooks/post-receive script.
martin-schanzenbach pushed a commit to branch master
in repository taldir.
The following commit(s) were added to refs/heads/master by this push:
new 4ac332f fix
4ac332f is described below
commit 4ac332f78aa21534fb752d8c3cfd269a31bbee2c
Author: Martin Schanzenbach <schanzen@gnunet.org>
AuthorDate: Tue Jul 12 15:36:25 2022 +0200
fix
---
pkg/rest/taldir.go | 32 ++++++++++++++++----------------
1 file changed, 16 insertions(+), 16 deletions(-)
diff --git a/pkg/rest/taldir.go b/pkg/rest/taldir.go
index 9c57a74..61c9a9e 100644
--- a/pkg/rest/taldir.go
+++ b/pkg/rest/taldir.go
@@ -166,7 +166,7 @@ type Order struct {
// Entry is a mapping from the identity key hash to a wallet key
// The identity key hash is sha512(sha512(address)|salt) where identity is
// one of the identity key types supported (e.g. an email address)
-type Entry struct {
+type entry struct {
// ORM
gorm.Model `json:"-"`
@@ -188,7 +188,7 @@ type Entry struct {
// The validation stores the identity key (sha256(identity)) the secret
// validation reference. The validation reference is sent to the identity
// depending on the out-of-band chennel defined through the identity key type.
-type Validation struct {
+type validation struct {
// ORM
gorm.Model `json:"-"`
@@ -295,7 +295,7 @@ const monthDuration = time.Duration(monthDurationUs * 1000)
// identity, e.g. SHA512(<email address>)
func (t *Taldir) getSingleEntry(w http.ResponseWriter, r *http.Request){
vars := mux.Vars(r)
- var entry Entry
+ var entry entry
hsAddress := saltHAddress(vars["h_address"], t.Salt)
var err = t.Db.First(&entry, "hs_address = ?", hsAddress).Error
if err == nil {
@@ -320,8 +320,8 @@ func saltHAddress(hAddress string, salt string) string {
// provided "out of band" using a validation method such as email or SMS
func (t *Taldir) validationRequest(w http.ResponseWriter, r *http.Request){
vars := mux.Vars(r)
- var entry Entry
- var validation Validation
+ var entry entry
+ var validation validation
var confirm ValidationConfirmation
var errDetail ErrorDetail
if r.Body == nil {
@@ -385,7 +385,7 @@ func (t *Taldir) validationRequest(w http.ResponseWriter, r
*http.Request){
}
func (t *Taldir) isRateLimited(hAddress string) (bool, error) {
- var validationMetadata ValidationMetadata
+ var validationMetadata validationMetadata
err := t.Db.First(&validationMetadata, "h_address = ?", hAddress).Error
// NOTE: Check rate limit
if err == nil {
@@ -417,8 +417,8 @@ func (t *Taldir) registerRequest(w http.ResponseWriter, r
*http.Request){
vars := mux.Vars(r)
var req RegisterMessage
var errDetail ErrorDetail
- var validation Validation
- var entry Entry
+ var validation validation
+ var entry entry
var order Order
if r.Body == nil {
http.Error(w, "No request body", 400)
@@ -605,7 +605,7 @@ func (t *Taldir) validationPage(w http.ResponseWriter, r
*http.Request) {
vars := mux.Vars(r)
var walletLink string
var png []byte
- var validation Validation
+ var validation validation
err := t.Db.First(&validation, "h_address = ?", vars["h_address"]).Error
w.Header().Set("Content-Type", "text/html; charset=utf-8")
@@ -633,9 +633,9 @@ func (t *Taldir) validationPage(w http.ResponseWriter, r
*http.Request) {
// ClearDatabase nukes the database (for tests)
func (t *Taldir) ClearDatabase() {
- t.Db.Where("1 = 1").Delete(&Entry{})
- t.Db.Where("1 = 1").Delete(&Validation{})
- t.Db.Where("1 = 1").Delete(&ValidationMetadata{})
+ t.Db.Where("1 = 1").Delete(&entry{})
+ t.Db.Where("1 = 1").Delete(&validation{})
+ t.Db.Where("1 = 1").Delete(&validationMetadata{})
}
func (t *Taldir) termsResponse(w http.ResponseWriter, r *http.Request) {
@@ -794,13 +794,13 @@ func (t *Taldir) Initialize(cfgfile string) {
panic(err)
}
t.Db = _db
- if err := t.Db.AutoMigrate(&Entry{}); err != nil {
+ if err := t.Db.AutoMigrate(&entry{}); err != nil {
panic(err)
}
- if err := t.Db.AutoMigrate(&Validation{}); err != nil {
+ if err := t.Db.AutoMigrate(&validation{}); err != nil {
panic(err)
}
- if err := t.Db.AutoMigrate(&ValidationMetadata{}); err != nil {
+ if err := t.Db.AutoMigrate(&validationMetadata{}); err != nil {
panic(err)
}
@@ -813,7 +813,7 @@ func (t *Taldir) Initialize(cfgfile string) {
}
go func() {
for true {
- tx := t.Db.Where("created_at < ?",
time.Now().Add(-validationExp)).Delete(&Validation{})
+ tx := t.Db.Where("created_at < ?",
time.Now().Add(-validationExp)).Delete(&validation{})
log.Printf("Cleaned up %d stale validations.\n", tx.RowsAffected)
time.Sleep(validationExp)
}
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.