Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
This repository was archived by the owner on Sep 2, 2024. It is now read-only.
/corePublic archive

Commit417482e

Browse files
committed
fixed issue with created user having no dateclose#106
1 parent9341533 commit417482e

File tree

6 files changed

+12
-1
lines changed

6 files changed

+12
-1
lines changed

‎account_test.go‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package staticbackend
22

33
import (
44
"testing"
5+
"time"
56

67
"github.com/staticbackendhq/core/backend"
78
"github.com/staticbackendhq/core/model"
@@ -34,6 +35,9 @@ func TestUserAddRemoveFromAccount(t *testing.T) {
3435
for_,user:=rangeusers {
3536
ifuser.Email=="newuser@test.com" {
3637
newUserID=user.ID
38+
if!user.Created.After(time.Now().Add(-2*time.Minute)) {
39+
t.Errorf("expected user to have a recent creation date, got %v",user.Created)
40+
}
3741
break
3842
}
3943
}

‎cache/cache.go‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,6 @@ func (c *Cache) Subscribe(send chan model.Command, token, channel string, close
108108
varmsg model.Command
109109
iferr:=json.Unmarshal([]byte(m.Payload),&msg);err!=nil {
110110
c.log.Error().Err(err).Msg("error parsing JSON message")
111-
_=pubsub.Close()
112111
return
113112
}
114113

‎database/memory/membership.go‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ func (m *Memory) CreateAccount(dbName, email string) (id string, err error) {
2121
}
2222

2323
func (m*Memory)CreateUser(dbNamestring,tok model.User) (idstring,errerror) {
24+
tok.Created=time.Now()
25+
2426
id=m.NewID()
2527
tok.ID=id
2628

‎database/mongo/membership.go‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ func (mg *Mongo) CreateAccount(dbName, email string) (id string, err error) {
4444
func (mg*Mongo)CreateUser(dbNamestring,tok model.User) (idstring,errerror) {
4545
db:=mg.Client.Database(dbName)
4646

47+
tok.Created=time.Now()
48+
4749
tok.ID=primitive.NewObjectID().Hex()
4850

4951
itok:=toLocalToken(tok)

‎database/postgresql/membership.go‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ func (pg *PostgreSQL) CreateAccount(dbName, email string) (id string, err error)
1919
}
2020

2121
func (pg*PostgreSQL)CreateUser(dbNamestring,tok model.User) (idstring,errerror) {
22+
tok.Created=time.Now()
23+
2224
qry:=fmt.Sprintf(`
2325
INSERT INTO %s.sb_tokens(account_id, email, password, token, role, reset_code, created)
2426
VALUES($1, $2, $3, $4, $5, $6, $7)

‎database/sqlite/membership.go‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ func (sl *SQLite) CreateAccount(dbName, email string) (id string, err error) {
2020
}
2121

2222
func (sl*SQLite)CreateUser(dbNamestring,tok model.User) (idstring,errerror) {
23+
tok.Created=time.Now()
24+
2325
id=sl.NewID()
2426

2527
qry:=fmt.Sprintf(`

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp