Open platform to collect and prioritize feedback
add migration and tenant to jwt claims
goenningd4ae2bd5d961
diff --git a/app/feedback/handler.go b/app/feedback/handler.goindex f59ad8a1f..940b286a3 100644--- a/app/feedback/handler.go+++ b/app/feedback/handler.go@@ -3,8 +3,6 @@ package feedbackimport ("strings"- "fmt"-"github.com/WeCanHearYou/wechy/app""github.com/labstack/echo")@@ -46,8 +44,6 @@ func (h AllHandlers) PostIdea() app.HandlerFunc {return c.Failure(err)}- fmt.Println(input)-if strings.Trim(input.Title, " ") == "" {return c.JSON(400, echo.Map{"message": "Idea title is required.",diff --git a/app/identity/jwt_test.go b/app/identity/jwt_test.goindex 19a540fae..6b741101e 100644--- a/app/identity/jwt_test.go+++ b/app/identity/jwt_test.go@@ -29,6 +29,7 @@ func TestJWT_Decode(t *testing.T) {UserID: 424,UserName: "Jon Snow",UserEmail: "[email protected]",+ TenantID: 2,}token, _ := identity.Encode(claims)@@ -38,4 +39,5 @@ func TestJWT_Decode(t *testing.T) {Expect(decoded.UserID).To(Equal(claims.UserID))Expect(decoded.UserName).To(Equal(claims.UserName))Expect(decoded.UserEmail).To(Equal(claims.UserEmail))+ Expect(decoded.TenantID).To(Equal(claims.TenantID))}diff --git a/app/model.go b/app/model.goindex 06be5ab1b..e88ae7b0a 100644--- a/app/model.go+++ b/app/model.go@@ -28,5 +28,6 @@ type WechyClaims struct {UserID int `json:"user/id"`UserName string `json:"user/name"`UserEmail string `json:"user/email"`+ TenantID int `json:"tenant/id"`jwt.StandardClaims}diff --git a/migrations/201703310857_add_tenant_to_users.up.sql b/migrations/201703310857_add_tenant_to_users.up.sqlnew file mode 100644index 000000000..75febb1f9--- /dev/null+++ b/migrations/201703310857_add_tenant_to_users.up.sql@@ -0,0 +1,10 @@+ALTER TABLE users ADD tenant_id INT REFERENCES tenants(id);++UPDATE users+SET tenant_id = ideas.tenant_id+FROM ideas+WHERE ideas.user_id = users.id;++UPDATE users+SET tenant_id = (SELECT id FROM tenants LIMIT 1)+WHERE tenant_id IS NULL\ No newline at end of file