Skip to content

Commit 7907825

Browse files
committed
Merge branch 'develop' and v0.12.7 hotfix
2 parents f697da9 + a3ac728 commit 7907825

File tree

12 files changed

+117
-69
lines changed

12 files changed

+117
-69
lines changed

docs/content/sdk/golang.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ go run main.go
9191

9292
If you see a message like the following, then congratulations! You've successfully connected to Ensign!
9393

94-
```HEALTHY 0.12.6-beta.21 ([GIT HASH])```
94+
```HEALTHY 0.12.7-beta.22 ([GIT HASH])```
9595

9696
### Make Some Data
9797

docs/content/sdk/python.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ If you see a message like the following, then congratulations! You've successful
7575

7676
```
7777
status: 1
78-
version: 0.12.6-beta.21 ([GIT HASH])
78+
version: 0.12.7-beta.22 ([GIT HASH])
7979
uptime: seconds: 130150
8080
nanos: 862300696
8181
```

pkg/quarterdeck/auth.go

+2-4
Original file line numberDiff line numberDiff line change
@@ -551,15 +551,14 @@ func (s *Server) refreshUser(c *gin.Context, userID, orgID any) (_ *tokens.Claim
551551
}
552552

553553
// Create a new claims object using the user retrieved from the database
554-
// TODO: add account type from database rather than hardcoding "sandbox"
555554
refreshClaims := &tokens.Claims{
556555
RegisteredClaims: jwt.RegisteredClaims{
557556
Subject: user.ID.String(),
558557
},
559558
Name: user.Name,
560559
Email: user.Email,
561560
Picture: gravatar.New(user.Email, nil),
562-
AccountType: "sandbox",
561+
AccountType: user.AccountType,
563562
}
564563

565564
// Add the orgID to the claims
@@ -742,7 +741,6 @@ func (s *Server) Switch(c *gin.Context) {
742741
// Create access and refresh tokens for new organization
743742
// NOTE: ensure that new claims are created and returned, not the old claims;
744743
// otherwise the user may receive incorrect permissions.
745-
// TODO: add account type from database rather than hardcoding "sandbox"
746744
newClaims := &tokens.Claims{
747745
RegisteredClaims: jwt.RegisteredClaims{
748746
Subject: user.ID.String(),
@@ -751,7 +749,7 @@ func (s *Server) Switch(c *gin.Context) {
751749
Email: user.Email,
752750
Picture: gravatar.New(user.Email, nil),
753751
OrgID: in.OrgID.String(),
754-
AccountType: "sandbox",
752+
AccountType: user.AccountType,
755753
}
756754

757755
// Add the user permissions to the claims
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
-- Add a column for tracking the user account type.
2+
3+
BEGIN;
4+
5+
ALTER TABLE users ADD COLUMN account_type TEXT DEFAULT 'sandbox';
6+
7+
COMMIT;

pkg/quarterdeck/db/models/models.go

+6
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,12 @@ type Base struct {
99
Modified string
1010
}
1111

12+
// Scanner is an interface for *sql.Rows and *sql.Row so that models can implement how
13+
// they scan fields into their struct without having to specify every field every time.
14+
type Scanner interface {
15+
Scan(dest ...any) error
16+
}
17+
1218
// Return the parsed created timestamp.
1319
func (b *Base) GetCreated() (time.Time, error) {
1420
return time.Parse(time.RFC3339Nano, b.Created)

pkg/quarterdeck/db/models/models_test.go

+4-2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package models_test
22

33
import (
44
"context"
5+
"fmt"
56
"os"
67
"path/filepath"
78
"testing"
@@ -29,7 +30,7 @@ func (m *modelTestSuite) SetupSuite() {
2930
// Creates a SQLite database with the current schema and the db module connected in a
3031
// temporary directory that will be cleaned up when the tests are complete.
3132
func (m *modelTestSuite) CreateDB() {
32-
require := m.Require()
33+
require := m.Assert()
3334

3435
// Only create the database path on the first call to CreateDB. Otherwise the call
3536
// to TempDir() will be prefixed with the name of the subtest, which will cause an
@@ -57,11 +58,12 @@ func (m *modelTestSuite) CreateDB() {
5758
}
5859

5960
tx.Commit()
61+
fmt.Printf("test database created at %s\n", m.dbpath)
6062
}
6163

6264
// Closes the connection to the current database and connects to a new database.
6365
func (m *modelTestSuite) ResetDB() {
64-
require := m.Require()
66+
require := m.Assert()
6567
require.NoError(db.Close(), "could not close connection to db")
6668
require.NoError(os.Remove(m.dbpath), "could not delete old db")
6769
m.CreateDB()

pkg/quarterdeck/db/models/testdata/fixtures.sql

+6-6
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,12 @@ INSERT INTO organizations (id, name, domain, created, modified) VALUES
1717
-- Sophia Thompson Password: livingthedream
1818
-- Robert Millser ULID: 01GRM2319FNCQM7H5P6H9PJ68A
1919
-- Robert Miller Password: weareonamission
20-
INSERT INTO users (id, name, email, password, terms_agreement, privacy_agreement, email_verified, email_verification_expires, email_verification_token, email_verification_secret, last_login, created, modified) VALUES
21-
(x'0184e32cccecff01c1205fa8dc9e20df', 'Jannel P. Hudson', '[email protected]', '$argon2id$v=19$m=65536,t=1,p=2$Ujy6FI2NBqRIUHmqH0YcQA==$f1lwLv4DpE4OTkMq3sTShZS3NHADg9UvnZNHtuUOmZ8=', 't', 't', 't', '2023-03-01T01:22:39Z', '3s855zxQxp-GEk_tgZkAzBxJUgzsWyUTlxIAee_dOJg', 'secret', '2022-12-13T01:22:39Z', '2022-12-05T16:44:34.924036Z', '2022-12-05T16:44:34.924036Z'),
22-
(x'0185df7210e5d8d7f6d33d7ecad99bbd', 'Edison Edgar Franklin', '[email protected]', '$argon2id$v=19$m=65536,t=1,p=2$x4Zh4ARSD4wK7uZFaauyjg==$eCkUszypW+rLvQ+D9lpfTgVwqPSKH13rCdmzV9vZ8cQ=', 't', 't', 't', '2023-03-02T01:22:39Z', '1HyHx3IHSG0G_1QPyyJugdyJATuXoGhWc2q9a7lg6rs', 'secret', '2023-02-14T14:48:08Z', '2023-01-23T16:24:32.741955Z', '2023-01-23T16:24:32.741955Z'),
23-
(x'0185fde9f80e6439a2ee58de062a3e34', 'Zendaya Longeye', '[email protected]', '$argon2id$v=19$m=65536,t=1,p=2$rQMSo/Lksd+/DazFmcuu4Q==$GtZGSh9SajnzXp/Cd8h/zpzgXrw4coXhRz/DhnG7GEU=', 't', 't', 't', '2023-03-03T01:22:39Z', '6riAupvFNaksIuGJWMn2wLU9PPpII4WYRllXgw_gG2M', 'secret', '2023-02-14T08:09:48.739212Z', '2023-01-29T14:24:07.182624Z', '2023-01-29T14:24:07.182624Z'),
24-
(x'018627cf1e8d2c5f4fdc91ffe01353de', 'Sophia Thompson', '[email protected]', '$argon2id$v=19$m=65536,t=1,p=2$SXvnfVpYqOkm+wFPr4VlaA==$1wSremsvEP6Bc2LjzlncjQZvJrO3sBxTLP3AIAu8weQ=', 't', 't', 't', '2023-03-04T01:22:39Z', 'vrArwUOFgp8iTrxgLj0bVrSmiR5mEIUrHF04N6FWDkM', 'secret', '2023-02-06T05:28:22.09Z', '2023-02-04T17:38:50.637565Z', '2023-02-04T17:38:50.637565Z'),
25-
(x'01862821852fab2f43c4b6345369190a', 'Robert Miller', '[email protected]', '$argon2id$v=19$m=65536,t=1,p=2$VFBxqapTyGeHhf4fkJkRjA==$QhYvYeDp/3KWCIkQDhrPCTvx2RLzPW0P2oc8ST9/Vgo=', 't', 't', 't', '2023-03-05T01:22:39Z', '61W2oUZC93ra9TJENqfhS5ulTjK4KHhL7AGb4_tfPDE', 'secret', '2023-02-06T05:29:23.08Z', '2023-02-04T19:08:50.863919Z', '2023-02-04T19:08:50.863919Z')
20+
INSERT INTO users (id, name, email, password, terms_agreement, privacy_agreement, account_type, email_verified, email_verification_expires, email_verification_token, email_verification_secret, last_login, created, modified) VALUES
21+
(x'0184e32cccecff01c1205fa8dc9e20df', 'Jannel P. Hudson', '[email protected]', '$argon2id$v=19$m=65536,t=1,p=2$Ujy6FI2NBqRIUHmqH0YcQA==$f1lwLv4DpE4OTkMq3sTShZS3NHADg9UvnZNHtuUOmZ8=', 't', 't', 'sandbox', 't', '2023-03-01T01:22:39Z', '3s855zxQxp-GEk_tgZkAzBxJUgzsWyUTlxIAee_dOJg', 'secret', '2022-12-13T01:22:39Z', '2022-12-05T16:44:34.924036Z', '2022-12-05T16:44:34.924036Z'),
22+
(x'0185df7210e5d8d7f6d33d7ecad99bbd', 'Edison Edgar Franklin', '[email protected]', '$argon2id$v=19$m=65536,t=1,p=2$x4Zh4ARSD4wK7uZFaauyjg==$eCkUszypW+rLvQ+D9lpfTgVwqPSKH13rCdmzV9vZ8cQ=', 't', 't', 'sandbox', 't', '2023-03-02T01:22:39Z', '1HyHx3IHSG0G_1QPyyJugdyJATuXoGhWc2q9a7lg6rs', 'secret', '2023-02-14T14:48:08Z', '2023-01-23T16:24:32.741955Z', '2023-01-23T16:24:32.741955Z'),
23+
(x'0185fde9f80e6439a2ee58de062a3e34', 'Zendaya Longeye', '[email protected]', '$argon2id$v=19$m=65536,t=1,p=2$rQMSo/Lksd+/DazFmcuu4Q==$GtZGSh9SajnzXp/Cd8h/zpzgXrw4coXhRz/DhnG7GEU=', 't', 't', 'sandbox', 't', '2023-03-03T01:22:39Z', '6riAupvFNaksIuGJWMn2wLU9PPpII4WYRllXgw_gG2M', 'secret', '2023-02-14T08:09:48.739212Z', '2023-01-29T14:24:07.182624Z', '2023-01-29T14:24:07.182624Z'),
24+
(x'018627cf1e8d2c5f4fdc91ffe01353de', 'Sophia Thompson', '[email protected]', '$argon2id$v=19$m=65536,t=1,p=2$SXvnfVpYqOkm+wFPr4VlaA==$1wSremsvEP6Bc2LjzlncjQZvJrO3sBxTLP3AIAu8weQ=', 't', 't', 'sandbox', 't', '2023-03-04T01:22:39Z', 'vrArwUOFgp8iTrxgLj0bVrSmiR5mEIUrHF04N6FWDkM', 'secret', '2023-02-06T05:28:22.09Z', '2023-02-04T17:38:50.637565Z', '2023-02-04T17:38:50.637565Z'),
25+
(x'01862821852fab2f43c4b6345369190a', 'Robert Miller', '[email protected]', '$argon2id$v=19$m=65536,t=1,p=2$VFBxqapTyGeHhf4fkJkRjA==$QhYvYeDp/3KWCIkQDhrPCTvx2RLzPW0P2oc8ST9/Vgo=', 't', 't', 'sandbox', 't', '2023-03-05T01:22:39Z', '61W2oUZC93ra9TJENqfhS5ulTjK4KHhL7AGb4_tfPDE', 'secret', '2023-02-06T05:29:23.08Z', '2023-02-04T19:08:50.863919Z', '2023-02-04T19:08:50.863919Z')
2626
;
2727

2828
INSERT INTO user_invitations (user_id, organization_id, role, email, expires, token, secret, created_by, created, modified) VALUES

0 commit comments

Comments
 (0)