Open platform to collect and prioritize feedback
Rename signin_requests and add kind as column (#245)
Guilherme Oenningd32d9c7b4c2f
diff --git a/app/actions/idea.go b/app/actions/idea.goindex e0f3276a3..3e1307e77 100644--- a/app/actions/idea.go+++ b/app/actions/idea.go@@ -34,6 +34,10 @@ func (input *CreateNewIdea) Validate(services *app.Services) *validate.Result {result.AddFieldFailure("title", "Title is required.")}+ if len(input.Model.Title) > 100 {+ result.AddFieldFailure("title", "Title must be less than 100 characters.")+ }+if len(input.Model.Title) < 10 || len(strings.Split(input.Model.Title, " ")) < 3 {result.AddFieldFailure("title", "Title needs to be more descriptive.")}@@ -81,6 +85,10 @@ func (input *UpdateIdea) Validate(services *app.Services) *validate.Result {result.AddFieldFailure("title", "Title needs to be more descriptive.")}+ if len(input.Model.Title) > 100 {+ result.AddFieldFailure("title", "Title must be less than 100 characters.")+ }+another, err := services.Ideas.GetBySlug(slug.Make(input.Model.Title))if err != nil && err != app.ErrNotFound {return validate.Error(err)diff --git a/app/actions/idea_test.go b/app/actions/idea_test.goindex a499d30d2..481c83fbd 100644--- a/app/actions/idea_test.go+++ b/app/actions/idea_test.go@@ -19,6 +19,7 @@ func TestCreateNewIdea_InvalidIdeaTitles(t *testing.T) {""," ","signup",+ "My great great great great great great great great great great great great great great great great great idea.","my company","my@company","my.company",diff --git a/app/actions/signin.go b/app/actions/signin.goindex 17e7b001a..38ad8f326 100644--- a/app/actions/signin.go+++ b/app/actions/signin.go@@ -78,7 +78,7 @@ func (input *CompleteProfile) Validate(services *app.Services) *validate.Resultif input.Model.Key == "" {result.AddFieldFailure("key", "Key is required.")} else {- request, err := services.Tenants.FindVerificationByKey(input.Model.Key)+ request, err := services.Tenants.FindVerificationByKey(models.EmailVerificationKindSignIn, input.Model.Key)if err != nil {if err == app.ErrNotFound {result.AddFieldFailure("key", "Key is invalid.")diff --git a/app/actions/signin_test.go b/app/actions/signin_test.goindex 6c78a948d..60ec2d35f 100644--- a/app/actions/signin_test.go+++ b/app/actions/signin_test.go@@ -65,7 +65,8 @@ func TestCompleteProfile_UnknownKey(t *testing.T) {func TestCompleteProfile_ValidKey(t *testing.T) {RegisterTestingT(t)- services.Tenants.SaveVerificationKey("1234567890", 15*time.Minute, "[email protected]", "")+ e := &models.SignInByEmail{Email: "[email protected]"}+ services.Tenants.SaveVerificationKey("1234567890", 15*time.Minute, e)action := actions.CompleteProfile{Model: &models.CompleteProfile{Name: "Jon Snow", Key: "1234567890"}}result := action.Validate(services)ExpectSuccess(result)diff --git a/app/handlers/signin.go b/app/handlers/signin.goindex fa58c2ecf..13a2d9245 100644--- a/app/handlers/signin.go+++ b/app/handlers/signin.go@@ -139,7 +139,7 @@ func SignInByEmail() web.HandlerFunc {return c.HandleValidation(result)}- err := c.Services().Tenants.SaveVerificationKey(input.Model.VerificationKey, 15*time.Minute, input.Model.Email, "")+ err := c.Services().Tenants.SaveVerificationKey(input.Model.VerificationKey, 15*time.Minute, input.Model)if err != nil {return c.Failure(err)}@@ -163,11 +163,11 @@ func SignInByEmail() web.HandlerFunc {}// VerifySignInKey checks if verify key is correct and sign in user-func VerifySignInKey() web.HandlerFunc {+func VerifySignInKey(kind models.EmailVerificationKind) web.HandlerFunc {return func(c web.Context) error {key := c.QueryParam("k")- result, err := c.Services().Tenants.FindVerificationByKey(key)+ result, err := c.Services().Tenants.FindVerificationByKey(kind, key)if err != nil {if err == app.ErrNotFound {return c.Redirect(http.StatusTemporaryRedirect, c.BaseURL())@@ -190,7 +190,7 @@ func VerifySignInKey() web.HandlerFunc {}var user *models.User- if c.Tenant().Status == models.TenantInactive {+ if kind == models.EmailVerificationKindSignUp && c.Tenant().Status == models.TenantInactive {if err = c.Services().Tenants.Activate(c.Tenant().ID); err != nil {return c.Failure(err)}@@ -205,7 +205,7 @@ func VerifySignInKey() web.HandlerFunc {if err = c.Services().Users.Register(user); err != nil {return c.Failure(err)}- } else {+ } else if kind == models.EmailVerificationKindSignIn {user, err = c.Services().Users.GetByEmail(c.Tenant().ID, result.Email)if err != nil {if err == app.ErrNotFound {@@ -214,6 +214,8 @@ func VerifySignInKey() web.HandlerFunc {}return c.Failure(err)}+ } else {+ return c.NotFound()}err = c.Services().Tenants.SetKeyAsVerified(key)diff --git a/app/handlers/signin_test.go b/app/handlers/signin_test.goindex 3f26d5f6b..de9cba650 100644--- a/app/handlers/signin_test.go+++ b/app/handlers/signin_test.go@@ -203,7 +203,7 @@ func TestVerifySignInKeyHandler_UnknownKey(t *testing.T) {code, response := server.OnTenant(mock.DemoTenant).WithURL("http://demo.test.fider.io/signin/verify?k=unknown").- Execute(handlers.VerifySignInKey())+ Execute(handlers.VerifySignInKey(models.EmailVerificationKindSignIn))Expect(code).To(Equal(http.StatusTemporaryRedirect))Expect(response.Header().Get("Location")).To(Equal("http://demo.test.fider.io"))@@ -214,13 +214,14 @@ func TestVerifySignInKeyHandler_UsedKey(t *testing.T) {server, services := mock.NewServer()- services.Tenants.SaveVerificationKey("1234567890", 15*time.Minute, "[email protected]", "")+ e := &models.SignInByEmail{Email: "[email protected]"}+ services.Tenants.SaveVerificationKey("1234567890", 15*time.Minute, e)services.Tenants.SetKeyAsVerified("1234567890")code, response := server.OnTenant(mock.DemoTenant).WithURL("http://demo.test.fider.io/signin/verify?k=1234567890").- Execute(handlers.VerifySignInKey())+ Execute(handlers.VerifySignInKey(models.EmailVerificationKindSignIn))Expect(code).To(Equal(http.StatusTemporaryRedirect))Expect(response.Header().Get("Location")).To(Equal("http://demo.test.fider.io"))@@ -231,14 +232,15 @@ func TestVerifySignInKeyHandler_ExpiredKey(t *testing.T) {server, services := mock.NewServer()- services.Tenants.SaveVerificationKey("1234567890", 5*time.Minute, "[email protected]", "")- request, _ := services.Tenants.FindVerificationByKey("1234567890")+ e := &models.SignInByEmail{Email: "[email protected]"}+ services.Tenants.SaveVerificationKey("1234567890", 5*time.Minute, e)+ request, _ := services.Tenants.FindVerificationByKey(models.EmailVerificationKindSignIn, "1234567890")request.ExpiresOn = request.CreatedOn.Add(-6 * time.Minute) //reduce 1 minutecode, response := server.OnTenant(mock.DemoTenant).WithURL("http://demo.test.fider.io/signin/verify?k=1234567890").- Execute(handlers.VerifySignInKey())+ Execute(handlers.VerifySignInKey(models.EmailVerificationKindSignIn))Expect(code).To(Equal(http.StatusTemporaryRedirect))Expect(response.Header().Get("Location")).To(Equal("http://demo.test.fider.io"))@@ -249,12 +251,13 @@ func TestVerifySignInKeyHandler_CorrectKey_ExistingUser(t *testing.T) {server, services := mock.NewServer()- services.Tenants.SaveVerificationKey("1234567890", 15*time.Minute, "[email protected]", "")+ e := &models.SignInByEmail{Email: "[email protected]"}+ services.Tenants.SaveVerificationKey("1234567890", 15*time.Minute, e)code, response := server.OnTenant(mock.DemoTenant).WithURL("http://demo.test.fider.io/signin/verify?k=1234567890").- Execute(handlers.VerifySignInKey())+ Execute(handlers.VerifySignInKey(models.EmailVerificationKindSignIn))token, _ := jwt.Encode(models.FiderClaims{UserID: mock.JonSnow.ID,@@ -272,12 +275,13 @@ func TestVerifySignInKeyHandler_CorrectKey_NewUser(t *testing.T) {server, services := mock.NewServer()- services.Tenants.SaveVerificationKey("1234567890", 15*time.Minute, "[email protected]", "")+ e := &models.SignInByEmail{Email: "[email protected]"}+ services.Tenants.SaveVerificationKey("1234567890", 15*time.Minute, e)code, _ := server.OnTenant(mock.DemoTenant).WithURL("http://demo.test.fider.io/signin/verify?k=1234567890").- Execute(handlers.VerifySignInKey())+ Execute(handlers.VerifySignInKey(models.EmailVerificationKindSignIn))Expect(code).To(Equal(http.StatusOK))}@@ -287,7 +291,8 @@ func TestVerifySignUpKeyHandler_InactiveTenant(t *testing.T) {server, services := mock.NewServer()- services.Tenants.SaveVerificationKey("1234567890", 15*time.Minute, "[email protected]", "Hot Pie")+ e := &models.CreateTenant{Email: "[email protected]", Name: "Hot Pie"}+ services.Tenants.SaveVerificationKey("1234567890", 15*time.Minute, e)mock.DemoTenant.Status = models.TenantInactivecode, response := server.@@ -320,7 +325,8 @@ func TestCompleteSignInProfileHandler_ExistingUser_CorrectKey(t *testing.T) {server, services := mock.NewServer()- services.Tenants.SaveVerificationKey("1234567890", 15*time.Minute, mock.JonSnow.Email, "")+ e := &models.SignInByEmail{Email: mock.JonSnow.Email}+ services.Tenants.SaveVerificationKey("1234567890", 15*time.Minute, e)code, _ := server.OnTenant(mock.DemoTenant).@@ -335,7 +341,8 @@ func TestCompleteSignInProfileHandler_CorrectKey(t *testing.T) {server, services := mock.NewServer()- services.Tenants.SaveVerificationKey("1234567890", 15*time.Minute, "[email protected]", "")+ e := &models.SignInByEmail{Email: "[email protected]"}+ services.Tenants.SaveVerificationKey("1234567890", 15*time.Minute, e)code, response := server.OnTenant(mock.DemoTenant).@@ -355,7 +362,7 @@ func TestCompleteSignInProfileHandler_CorrectKey(t *testing.T) {})Expect(response.Header().Get("Set-Cookie")).To(ContainSubstring(fmt.Sprintf("%s=%s;", web.CookieAuthName, token)))- request, err := services.Tenants.FindVerificationByKey("1234567890")+ request, err := services.Tenants.FindVerificationByKey(models.EmailVerificationKindSignIn, "1234567890")Expect(err).To(BeNil())Expect(request.VerifiedOn).NotTo(BeNil())}diff --git a/app/handlers/signup.go b/app/handlers/signup.goindex 65b919185..a3e175238 100644--- a/app/handlers/signup.go+++ b/app/handlers/signup.go@@ -67,7 +67,7 @@ func CreateTenant() web.HandlerFunc {user.Name = input.Model.Nameuser.Email = input.Model.Email- err := c.Services().Tenants.SaveVerificationKey(input.Model.VerificationKey, 48*time.Hour, user.Email, user.Name)+ err := c.Services().Tenants.SaveVerificationKey(input.Model.VerificationKey, 48*time.Hour, input.Model)if err != nil {return c.Failure(err)}@@ -125,7 +125,7 @@ func SignUp() web.HandlerFunc {func VerifySignUpKey() web.HandlerFunc {return func(c web.Context) error {if c.Tenant().Status == models.TenantInactive {- return VerifySignInKey()(c)+ return VerifySignInKey(models.EmailVerificationKindSignUp)(c)}return c.NotFound()}diff --git a/app/models/identity.go b/app/models/identity.goindex 6c79b9c2e..7c6e589e6 100644--- a/app/models/identity.go+++ b/app/models/identity.go@@ -46,6 +46,16 @@ const (RoleAdministrator Role = 3)+//EmailVerificationKind specifies which kind of process is being verified by e-mail+type EmailVerificationKind int16++const (+ //EmailVerificationKindSignIn is the sign in by e-mail process+ EmailVerificationKindSignIn EmailVerificationKind = 1+ //EmailVerificationKindSignUp is the sign up (create tenant) by name and e-mail process+ EmailVerificationKindSignUp EmailVerificationKind = 2+)+//HasProvider returns true if current user has registered with given providerfunc (u *User) HasProvider(provider string) bool {for _, p := range u.Providers {@@ -100,6 +110,21 @@ type CreateTenant struct {UserClaims *OAuthClaims}+//GetEmail returns the email being verified+func (e *CreateTenant) GetEmail() string {+ return e.Email+}++//GetName returns the name of the email owner+func (e *CreateTenant) GetName() string {+ return e.Name+}++//GetKind returns EmailVerificationKindSignUp+func (e *CreateTenant) GetKind() EmailVerificationKind {+ return EmailVerificationKindSignUp+}+//UpdateTenantSettings is the input model used to update tenant settingstype UpdateTenantSettings struct {Title string `json:"title"`@@ -115,11 +140,34 @@ type SignInByEmail struct {VerificationKey string}-//SignInRequest is the model used by e-mail verification process-type SignInRequest struct {+//GetEmail returns the email being verified+func (e *SignInByEmail) GetEmail() string {+ return e.Email+}++//GetName returns empty for this kind of process+func (e *SignInByEmail) GetName() string {+ return ""+}++//GetKind returns EmailVerificationKindSignIn+func (e *SignInByEmail) GetKind() EmailVerificationKind {+ return EmailVerificationKindSignIn+}++//NewEmailVerification is used to register a new e-mail verification process+type NewEmailVerification interface {+ GetEmail() string+ GetName() string+ GetKind() EmailVerificationKind+}++//EmailVerification is the model used by e-mail verification process+type EmailVerification struct {Email stringName stringKey string+ Kind EmailVerificationKindCreatedOn time.TimeExpiresOn time.TimeVerifiedOn *time.Timediff --git a/app/storage/inmemory/tenant.go b/app/storage/inmemory/tenant.goindex 181b8283a..a946b6928 100644--- a/app/storage/inmemory/tenant.go+++ b/app/storage/inmemory/tenant.go@@ -11,11 +11,11 @@ import (// TenantStorage contains read and write operations for tenantstype TenantStorage struct {- lastID int- tenants []*models.Tenant- current *models.Tenant- user *models.User- requests []*models.SignInRequest+ lastID int+ tenants []*models.Tenant+ current *models.Tenant+ user *models.User+ verifications []*models.EmailVerification}// SetCurrentTenant tenant@@ -102,10 +102,11 @@ func (s *TenantStorage) Activate(id int) error {}// SaveVerificationKey used by e-mail verification-func (s *TenantStorage) SaveVerificationKey(key string, duration time.Duration, email, name string) error {- s.requests = append(s.requests, &models.SignInRequest{- Email: email,- Name: name,+func (s *TenantStorage) SaveVerificationKey(key string, duration time.Duration, request models.NewEmailVerification) error {+ s.verifications = append(s.verifications, &models.EmailVerification{+ Email: request.GetEmail(),+ Name: request.GetName(),+ Kind: request.GetKind(),Key: key,CreatedOn: time.Now(),ExpiresOn: time.Now().Add(duration),@@ -115,10 +116,10 @@ func (s *TenantStorage) SaveVerificationKey(key string, duration time.Duration,}// FindVerificationByKey based on current tenant-func (s *TenantStorage) FindVerificationByKey(key string) (*models.SignInRequest, error) {- for _, request := range s.requests {- if request.Key == key {- return request, nil+func (s *TenantStorage) FindVerificationByKey(kind models.EmailVerificationKind, key string) (*models.EmailVerification, error) {+ for _, verification := range s.verifications {+ if verification.Key == key && verification.Kind == kind {+ return verification, nil}}return nil, app.ErrNotFound@@ -126,10 +127,10 @@ func (s *TenantStorage) FindVerificationByKey(key string) (*models.SignInRequest// SetKeyAsVerified so that it cannot be used anymorefunc (s *TenantStorage) SetKeyAsVerified(key string) error {- for _, request := range s.requests {- if request.Key == key {+ for _, verification := range s.verifications {+ if verification.Key == key {now := time.Now()- request.VerifiedOn = &now+ verification.VerifiedOn = &now}}return nildiff --git a/app/storage/postgres/tenant.go b/app/storage/postgres/tenant.goindex 447756e7c..de0914e8d 100644--- a/app/storage/postgres/tenant.go+++ b/app/storage/postgres/tenant.go@@ -35,21 +35,23 @@ func (t *dbTenant) toModel() *models.Tenant {}}-type dbSignInRequest struct {- ID int `db:"id"`- Name string `db:"name"`- Email string `db:"email"`- Key string `db:"key"`- CreatedOn time.Time `db:"created_on"`- ExpiresOn time.Time `db:"expires_on"`- VerifiedOn dbx.NullTime `db:"verified_on"`-}--func (t *dbSignInRequest) toModel() *models.SignInRequest {- model := &models.SignInRequest{+type dbEmailVerification struct {+ ID int `db:"id"`+ Name string `db:"name"`+ Email string `db:"email"`+ Key string `db:"key"`+ Kind models.EmailVerificationKind `db:"kind"`+ CreatedOn time.Time `db:"created_on"`+ ExpiresOn time.Time `db:"expires_on"`+ VerifiedOn dbx.NullTime `db:"verified_on"`+}++func (t *dbEmailVerification) toModel() *models.EmailVerification {+ model := &models.EmailVerification{Name: t.Name,Email: t.Email,Key: t.Key,+ Kind: t.Kind,CreatedOn: t.CreatedOn,ExpiresOn: t.ExpiresOn,VerifiedOn: nil,@@ -146,26 +148,27 @@ func (s *TenantStorage) Activate(id int) error {}// SaveVerificationKey used by e-mail verification process-func (s *TenantStorage) SaveVerificationKey(key string, duration time.Duration, email, name string) error {- query := "INSERT INTO signin_requests (tenant_id, email, created_on, expires_on, key, name) VALUES ($1, $2, $3, $4, $5, $6)"- return s.trx.Execute(query, s.current.ID, email, time.Now(), time.Now().Add(duration), key, name)+func (s *TenantStorage) SaveVerificationKey(key string, duration time.Duration, request models.NewEmailVerification) error {+ query := "INSERT INTO email_verifications (tenant_id, email, created_on, expires_on, key, name, kind) VALUES ($1, $2, $3, $4, $5, $6, $7)"+ return s.trx.Execute(query, s.current.ID, request.GetEmail(), time.Now(), time.Now().Add(duration), key, request.GetName(), request.GetKind())}// FindVerificationByKey based on current tenant-func (s *TenantStorage) FindVerificationByKey(key string) (*models.SignInRequest, error) {- request := dbSignInRequest{}+func (s *TenantStorage) FindVerificationByKey(kind models.EmailVerificationKind, key string) (*models.EmailVerification, error) {+ verification := dbEmailVerification{}- err := s.trx.Get(&request, "SELECT id, email, name, key, created_on, verified_on, expires_on FROM signin_requests WHERE key = $1 LIMIT 1", key)+ query := "SELECT id, email, name, key, created_on, verified_on, expires_on, kind FROM email_verifications WHERE key = $1 AND kind = $2 LIMIT 1"+ err := s.trx.Get(&verification, query, key, kind)if err != nil {return nil, err}- return request.toModel(), nil+ return verification.toModel(), nil}// SetKeyAsVerified so that it cannot be used anymorefunc (s *TenantStorage) SetKeyAsVerified(key string) error {- query := "UPDATE signin_requests SET verified_on = $1 WHERE tenant_id = $2 AND key = $3"+ query := "UPDATE email_verifications SET verified_on = $1 WHERE tenant_id = $2 AND key = $3"return s.trx.Execute(query, time.Now(), s.current.ID, key)}diff --git a/app/storage/postgres/tenant_test.go b/app/storage/postgres/tenant_test.goindex 665e62ea4..5acf5c806 100644--- a/app/storage/postgres/tenant_test.go+++ b/app/storage/postgres/tenant_test.go@@ -144,16 +144,21 @@ func TestTenantStorage_SaveFindSet_VerificationKey(t *testing.T) {tenants.SetCurrentTenant(tenant)//Save new Key- err := tenants.SaveVerificationKey("s3cr3tk3y", 15*time.Minute, "[email protected]", "Jon Snow")+ request := &models.CreateTenant{+ Email: "[email protected]",+ Name: "Jon Snow",+ }+ err := tenants.SaveVerificationKey("s3cr3tk3y", 15*time.Minute, request)Expect(err).To(BeNil())//Find and check values- result, err := tenants.FindVerificationByKey("s3cr3tk3y")+ result, err := tenants.FindVerificationByKey(models.EmailVerificationKindSignUp, "s3cr3tk3y")Expect(err).To(BeNil())Expect(result.CreatedOn).NotTo(Equal(time.Time{}))Expect(result.VerifiedOn).To(BeNil())Expect(result.Email).To(Equal("[email protected]"))Expect(result.Name).To(Equal("Jon Snow"))+ Expect(result.Kind).To(Equal(models.EmailVerificationKindSignUp))Expect(result.Key).To(Equal("s3cr3tk3y"))Expect(result.ExpiresOn).To(BeTemporally("~", result.CreatedOn.Add(15*time.Minute), 1*time.Second))@@ -162,7 +167,7 @@ func TestTenantStorage_SaveFindSet_VerificationKey(t *testing.T) {Expect(err).To(BeNil())//Find and check that VerifiedOn is now set- result, err = tenants.FindVerificationByKey("s3cr3tk3y")+ result, err = tenants.FindVerificationByKey(models.EmailVerificationKindSignUp, "s3cr3tk3y")Expect(err).To(BeNil())Expect(time.Now().After(result.CreatedOn)).To(BeTrue())Expect(result.VerifiedOn.After(result.CreatedOn)).To(BeTrue())@@ -170,6 +175,11 @@ func TestTenantStorage_SaveFindSet_VerificationKey(t *testing.T) {Expect(result.Name).To(Equal("Jon Snow"))Expect(result.Key).To(Equal("s3cr3tk3y"))Expect(result.ExpiresOn).To(BeTemporally("~", result.CreatedOn.Add(15*time.Minute), 1*time.Second))++ //Wrong kind should not find it+ result, err = tenants.FindVerificationByKey(models.EmailVerificationKindSignIn, "s3cr3tk3y")+ Expect(err).To(Equal(app.ErrNotFound))+ Expect(result).To(BeNil())}func TestTenantStorage_FindUnknownVerificationKey(t *testing.T) {@@ -180,7 +190,7 @@ func TestTenantStorage_FindUnknownVerificationKey(t *testing.T) {tenants.SetCurrentTenant(tenant)//Find and check values- result, err := tenants.FindVerificationByKey("blahblahblah")+ result, err := tenants.FindVerificationByKey(models.EmailVerificationKindSignIn, "blahblahblah")Expect(err).To(Equal(app.ErrNotFound))Expect(result).To(BeNil())}diff --git a/app/storage/storage.go b/app/storage/storage.goindex 09eaa981c..a95adb79e 100644--- a/app/storage/storage.go+++ b/app/storage/storage.go@@ -54,8 +54,8 @@ type Tenant interface {UpdateSettings(settings *models.UpdateTenantSettings) errorIsSubdomainAvailable(subdomain string) (bool, error)IsCNAMEAvailable(cname string) (bool, error)- SaveVerificationKey(key string, duration time.Duration, email, name string) error- FindVerificationByKey(key string) (*models.SignInRequest, error)+ SaveVerificationKey(key string, duration time.Duration, request models.NewEmailVerification) error+ FindVerificationByKey(kind models.EmailVerificationKind, key string) (*models.EmailVerification, error)SetKeyAsVerified(key string) error}diff --git a/migrations/201801152006_rename_signin_requests.up.sql b/migrations/201801152006_rename_signin_requests.up.sqlnew file mode 100644index 000000000..7674c7ce7--- /dev/null+++ b/migrations/201801152006_rename_signin_requests.up.sql@@ -0,0 +1,3 @@+ALTER TABLE signin_requests RENAME TO email_verifications;+ALTER INDEX signin_requests_pkey RENAME TO email_verifications_pkey;+ALTER INDEX signin_requests_key_idx RENAME TO email_verifications_key_idx;\ No newline at end of filediff --git a/migrations/201801152017_add_kind_email_verification.up.sql b/migrations/201801152017_add_kind_email_verification.up.sqlnew file mode 100644index 000000000..e1126fc8f--- /dev/null+++ b/migrations/201801152017_add_kind_email_verification.up.sql@@ -0,0 +1,8 @@+ALTER TABLE email_verifications ADD kind smallint NULL;++UPDATE email_verifications SET kind = 1 WHERE name IS NULL OR name = '';+UPDATE email_verifications SET kind = 2 WHERE name IS NOT NULL AND name != '';++ALTER TABLE email_verifications ALTER COLUMN kind SET NOT NULL;++ALTER TABLE email_verifications ADD user_id INT NULL REFERENCES users (id)\ No newline at end of filediff --git a/public/pages/site/ShowIdeaPage/ShowIdeaPage.tsx b/public/pages/site/ShowIdeaPage/ShowIdeaPage.tsxindex fa83adedb..da9b2845b 100644--- a/public/pages/site/ShowIdeaPage/ShowIdeaPage.tsx+++ b/public/pages/site/ShowIdeaPage/ShowIdeaPage.tsx@@ -66,7 +66,7 @@ export class ShowIdeaPage extends React.Component<ShowIdeaPageProps, ShowIdeaPag{ this.state.editMode? [<div key={1} className="ui input huge fluid">- <input type="text" onChange={(e) => this.setState({ newTitle: e.currentTarget.value })} defaultValue={this.state.newTitle} />+ <input type="text" maxLength={100} onChange={(e) => this.setState({ newTitle: e.currentTarget.value })} defaultValue={this.state.newTitle} /></div>,<DisplayError key={0} fields={['title']} pointing="above" error={this.state.error} />]diff --git a/routes.go b/routes.goindex b6f018aaf..e69f48129 100644--- a/routes.go+++ b/routes.go@@ -88,7 +88,7 @@ func GetMainEngine(settings *models.AppSettings) *web.Engine {public.Get("/ideas/:number", handlers.IdeaDetails())public.Get("/ideas/:number/*all", handlers.IdeaDetails())public.Get("/signout", handlers.SignOut())- public.Get("/signin/verify", handlers.VerifySignInKey())+ public.Get("/signin/verify", handlers.VerifySignInKey(models.EmailVerificationKindSignIn))public.Get("/api/status", handlers.Status(settings))public.Post("/api/signin/complete", handlers.CompleteSignInProfile())public.Post("/api/signin", handlers.SignInByEmail())