-
-
Notifications
You must be signed in to change notification settings - Fork 638
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1194 from mattwoberts/userlist
Userlist Integration
- Loading branch information
Showing
19 changed files
with
732 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package cmd | ||
|
||
import "github.com/getfider/fider/app/models/enum" | ||
|
||
type UserListCreateCompany struct { | ||
Name string | ||
TenantId int | ||
SignedUpAt string | ||
BillingStatus string | ||
Subdomain string | ||
UserId int | ||
UserEmail string | ||
UserName string | ||
} | ||
|
||
type UserListUpdateCompany struct { | ||
TenantId int | ||
Name string | ||
BillingStatus enum.BillingStatus | ||
} | ||
|
||
type UserListUpdateUser struct { | ||
Id int | ||
TenantId int | ||
Email string | ||
Name string | ||
} | ||
|
||
type UserListHandleRoleChange struct { | ||
Id int | ||
Role enum.Role | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package dto | ||
|
||
import "github.com/getfider/fider/app/models/enum" | ||
|
||
type UserListUpdateCompany struct { | ||
TenantID int | ||
Name string | ||
BillingStatus enum.BillingStatus | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,3 +30,15 @@ INSERT INTO users (name, email, tenant_id, created_at, role, status, avatar_type | |
VALUES ('The Hulk', '[email protected]', 2, now(), 1, 1, 2, ''); | ||
INSERT INTO user_providers (user_id, tenant_id, provider, provider_uid, created_at) | ||
VALUES (5, 2, 'google', 'GO1111', now()); | ||
|
||
-- Create a tenant that has reached the end of it's trial period | ||
INSERT INTO tenants (name, subdomain, created_at, cname, invitation, welcome_message, status, is_private, custom_css, logo_bkey, locale, is_email_auth_allowed) | ||
VALUES ('Trial Expired', 'trial-expired', now(), 'feedback.trial-expired.com', '', '', 1, false, '', '', 'en', true); | ||
INSERT INTO tenants_billing (tenant_id, paddle_plan_id, paddle_subscription_id, status, subscription_ends_at, trial_ends_at) | ||
VALUES (3, 1, 1,1, now(), CURRENT_DATE - INTERVAL '10 days'); | ||
INSERT INTO users (name, email, tenant_id, created_at, role, status, avatar_type, avatar_bkey) | ||
VALUES ('Trial Expired', '[email protected]', 3, now(), 3, 1, 2, ''); | ||
INSERT INTO user_providers (user_id, tenant_id, provider, provider_uid, created_at) | ||
VALUES (6, 3, 'facebook', 'FB3333', now()); | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package postgres_test | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/getfider/fider/app/models/cmd" | ||
|
||
. "github.com/getfider/fider/app/pkg/assert" | ||
"github.com/getfider/fider/app/pkg/bus" | ||
) | ||
|
||
func TestLockExpiredTenants_ShouldTriggerForOneTenant(t *testing.T) { | ||
ctx := SetupDatabaseTest(t) | ||
defer TeardownDatabaseTest() | ||
|
||
// There is a tenant with an expired trial setup in the seed for the test database. | ||
q := &cmd.LockExpiredTenants{} | ||
|
||
err := bus.Dispatch(ctx, q) | ||
Expect(err).IsNil() | ||
Expect(q.NumOfTenantsLocked).Equals(int64(1)) | ||
Expect(q.TenantsLocked).Equals([]int{3}) | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -124,7 +124,7 @@ func TestUserStorage_Register(t *testing.T) { | |
err = bus.Dispatch(demoTenantCtx, getUser) | ||
Expect(err).IsNil() | ||
|
||
Expect(getUser.Result.ID).Equals(int(6)) | ||
Expect(getUser.Result.ID).Equals(int(7)) | ||
Expect(getUser.Result.Role).Equals(enum.RoleCollaborator) | ||
Expect(getUser.Result.Name).Equals("Rob Stark") | ||
Expect(getUser.Result.Email).Equals("[email protected]") | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package userlist_mock | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/getfider/fider/app/models/entity" | ||
"github.com/getfider/fider/app/models/enum" | ||
"github.com/getfider/fider/app/models/query" | ||
"github.com/getfider/fider/app/pkg/bus" | ||
) | ||
|
||
type Service struct{} | ||
|
||
func (s Service) Name() string { | ||
return "PostgreSQL" | ||
} | ||
|
||
func (s Service) Category() string { | ||
return "sqlstore" | ||
} | ||
|
||
func (s Service) Enabled() bool { | ||
return true | ||
} | ||
|
||
func (s Service) Init() { | ||
bus.AddHandler(GetUserByID) | ||
} | ||
|
||
func GetUserByID(ctx context.Context, q *query.GetUserByID) error { | ||
q.Result = &entity.User{ | ||
ID: 1, | ||
Name: "John Doe", | ||
Email: "[email protected]", | ||
Tenant: &entity.Tenant{ID: 1, Name: "Example Tenant"}, | ||
Role: enum.RoleAdministrator, | ||
Providers: []*entity.UserProvider{}, | ||
Status: enum.UserActive, | ||
} | ||
return nil | ||
} |
Oops, something went wrong.