Open platform to collect and prioritize feedback
enhancement: show more details when tenant is on pending status (#611)
Guilherme Oenningaa8bfb0941d3
diff --git a/app/handlers/signin.go b/app/handlers/signin.goindex 7a25bf26e..cbdc79239 100644--- a/app/handlers/signin.go+++ b/app/handlers/signin.go@@ -64,7 +64,7 @@ func VerifySignInKey(kind models.EmailVerificationKind) web.HandlerFunc {}var user *models.User- if kind == models.EmailVerificationKindSignUp && c.Tenant().Status == models.TenantInactive {+ if kind == models.EmailVerificationKindSignUp && c.Tenant().Status == models.TenantPending {if err = c.Services().Tenants.Activate(c.Tenant().ID); err != nil {return c.Failure(err)}diff --git a/app/handlers/signin_test.go b/app/handlers/signin_test.goindex 434e9b8dc..e3188b952 100644--- a/app/handlers/signin_test.go+++ b/app/handlers/signin_test.go@@ -207,7 +207,7 @@ func TestVerifySignUpKeyHandler_InactiveTenant(t *testing.T) {e := &models.CreateTenant{Email: "[email protected]", Name: "Hot Pie"}services.Tenants.SaveVerificationKey("1234567890", 15*time.Minute, e)- mock.DemoTenant.Status = models.TenantInactive+ mock.DemoTenant.Status = models.TenantPendingcode, response := server.OnTenant(mock.DemoTenant).diff --git a/app/handlers/signup.go b/app/handlers/signup.goindex 070ae8bae..94621f256 100644--- a/app/handlers/signup.go+++ b/app/handlers/signup.go@@ -44,7 +44,7 @@ func CreateTenant() web.HandlerFunc {socialSignUp := input.Model.Token != ""- status := models.TenantInactive+ status := models.TenantPendingif socialSignUp {status = models.TenantActive}@@ -123,7 +123,7 @@ func SignUp() web.HandlerFunc {// VerifySignUpKey checks if verify key is correct, activate the tenant and sign in userfunc VerifySignUpKey() web.HandlerFunc {return func(c web.Context) error {- if c.Tenant().Status == models.TenantInactive {+ if c.Tenant().Status == models.TenantPending {return VerifySignInKey(models.EmailVerificationKindSignUp)(c)}return c.NotFound()diff --git a/app/handlers/signup_test.go b/app/handlers/signup_test.goindex b1832ff16..2a8e8f634 100644--- a/app/handlers/signup_test.go+++ b/app/handlers/signup_test.go@@ -211,7 +211,7 @@ func TestCreateTenantHandler_WithEmailAndName(t *testing.T) {Expect(err).IsNil()Expect(tenant.Name).Equals("My Company")Expect(tenant.Subdomain).Equals("mycompany")- Expect(tenant.Status).Equals(models.TenantInactive)+ Expect(tenant.Status).Equals(models.TenantPending)user, err := services.Users.GetByEmail("[email protected]")Expect(errors.Cause(err)).Equals(app.ErrNotFound)diff --git a/app/middlewares/tenant.go b/app/middlewares/tenant.goindex a609d5471..74493c29a 100644--- a/app/middlewares/tenant.go+++ b/app/middlewares/tenant.go@@ -2,6 +2,7 @@ package middlewaresimport ("fmt"+ "net/http""github.com/getfider/fider/app/models"@@ -96,7 +97,10 @@ func OnlyActiveTenants() web.MiddlewareFunc {if c.Tenant().Status == models.TenantActive {return next(c)}- return c.NotFound()+ return c.Render(http.StatusOK, "pending-activation.html", web.Props{+ Title: "Pending Activation",+ Description: "We sent you a confirmation email with a link to activate your site. Please check your inbox to activate it.",+ })}}}diff --git a/app/middlewares/tenant_test.go b/app/middlewares/tenant_test.goindex b2fb8694f..46d423473 100644--- a/app/middlewares/tenant_test.go+++ b/app/middlewares/tenant_test.go@@ -190,14 +190,14 @@ func TestOnlyActiveTenants_Inactive(t *testing.T) {RegisterT(t)server, _ := mock.NewServer()- mock.DemoTenant.Status = models.TenantInactive+ mock.DemoTenant.Status = models.TenantPendingserver.Use(middlewares.OnlyActiveTenants())status, _ := server.OnTenant(mock.DemoTenant).Execute(func(c web.Context) error {- return c.NoContent(http.StatusOK)+ return c.NoContent(http.StatusTeapot)})- Expect(status).Equals(http.StatusNotFound)+ Expect(status).Equals(http.StatusOK)}func TestCheckTenantPrivacy_Private_Unauthenticated(t *testing.T) {diff --git a/app/models/identity.go b/app/models/identity.goindex 408ba2753..386b4868e 100644--- a/app/models/identity.go+++ b/app/models/identity.go@@ -24,8 +24,8 @@ type Tenant struct {var (//TenantActive is the default status for most tenantsTenantActive = 1- //TenantInactive is used for signup via email that requires user confirmation- TenantInactive = 2+ //TenantPending is used for signup via email that requires user confirmation+ TenantPending = 2)//Upload represents a file that has been uploaded to Fiderdiff --git a/app/storage/postgres/tenant_test.go b/app/storage/postgres/tenant_test.goindex db3e9e644..ff9f7d65e 100644--- a/app/storage/postgres/tenant_test.go+++ b/app/storage/postgres/tenant_test.go@@ -18,7 +18,7 @@ func TestTenantStorage_Add_Activate(t *testing.T) {SetupDatabaseTest(t)defer TeardownDatabaseTest()- tenant, err := tenants.Add("My Domain Inc.", "mydomain", models.TenantInactive)+ tenant, err := tenants.Add("My Domain Inc.", "mydomain", models.TenantPending)Expect(err).IsNil()Expect(tenant).IsNotNil()@@ -27,7 +27,7 @@ func TestTenantStorage_Add_Activate(t *testing.T) {Expect(err).IsNil()Expect(tenant.Name).Equals("My Domain Inc.")Expect(tenant.Subdomain).Equals("mydomain")- Expect(tenant.Status).Equals(models.TenantInactive)+ Expect(tenant.Status).Equals(models.TenantPending)Expect(tenant.IsPrivate).IsFalse()err = tenants.Activate(tenant.ID)@@ -47,7 +47,7 @@ func TestTenantStorage_SingleTenant_Add(t *testing.T) {os.Setenv("HOST_MODE", "single")- tenant, err := tenants.Add("My Domain Inc.", "mydomain", models.TenantInactive)+ tenant, err := tenants.Add("My Domain Inc.", "mydomain", models.TenantPending)Expect(err).IsNil()Expect(tenant).IsNotNil()}diff --git a/views/pending-activation.html b/views/pending-activation.htmlnew file mode 100644index 000000000..e475763cd--- /dev/null+++ b/views/pending-activation.html@@ -0,0 +1,14 @@+{{define "title"}}+Pending Activation · Fider+{{end}}++{{define "javascript"}}{{end}}++{{define "content"}}+<div class="container failure-page">+ <img src="{{.__logo}}"/>+ <h1>YOUR ACCOUNT IS PENDING ACTIVATION</h1>+ <p>We sent you a confirmation email with a link to activate your site.</p>+ <p>Please check your inbox to activate it.</p>+</div>+{{end}}\ No newline at end of file