Open platform to collect and prioritize feedback
Fixes to the sign in flow for new users.
Matt Roberts8f78e39fcc4d
diff --git a/app/handlers/signin.go b/app/handlers/signin.goindex 4ad1bb2f6..df03aa133 100644--- a/app/handlers/signin.go+++ b/app/handlers/signin.go@@ -286,26 +286,38 @@ func VerifySignInKey(kind enum.EmailVerificationKind) web.HandlerFunc {return NotInvitedPage()(c)}- // User should already have entered their name so we can get them registered.- user := &entity.User{- Name: result.Name,- Email: result.Email,- Tenant: c.Tenant(),- Role: enum.RoleVisitor,- }- err = bus.Dispatch(c, &cmd.RegisterUser{User: user})- if err != nil {- return c.Failure(err)- }+ // If name is provided in verification, create user account immediately+ if result.Name != "" {+ user := &entity.User{+ Name: result.Name,+ Email: result.Email,+ Tenant: c.Tenant(),+ Role: enum.RoleVisitor,+ }+ err = bus.Dispatch(c, &cmd.RegisterUser{User: user})+ if err != nil {+ return c.Failure(err)+ }- err = bus.Dispatch(c, &cmd.SetKeyAsVerified{Key: key})- if err != nil {- return c.Failure(err)+ err = bus.Dispatch(c, &cmd.SetKeyAsVerified{Key: key})+ if err != nil {+ return c.Failure(err)+ }++ webutil.AddAuthUserCookie(c, user)+ baseURL := c.BaseURL()+ return c.Redirect(baseURL)}- webutil.AddAuthUserCookie(c, user)- baseURL := c.BaseURL()- return c.Redirect(baseURL)+ // Otherwise, show profile completion page+ return c.Page(http.StatusOK, web.Props{+ Page: "SignIn/CompleteSignInProfile.page",+ Title: "Complete Sign In Profile",+ Data: web.Map{+ "kind": kind,+ "k": key,+ },+ })}return c.Failure(err)diff --git a/app/handlers/signin_test.go b/app/handlers/signin_test.goindex 88f1fcdd9..f00ea8d15 100644--- a/app/handlers/signin_test.go+++ b/app/handlers/signin_test.go@@ -357,6 +357,56 @@ func TestVerifySignInKeyHandler_CorrectKey_NewUser(t *testing.T) {Expect(code).Equals(http.StatusOK)}+func TestVerifySignInKeyHandler_CorrectKey_NewUser_WithName(t *testing.T) {+ RegisterT(t)++ bus.AddHandler(func(ctx context.Context, q *query.GetUserByEmail) error {+ return app.ErrNotFound+ })++ key := "1234567890"+ bus.AddHandler(func(ctx context.Context, q *query.GetVerificationByKey) error {+ if q.Key == key && q.Kind == enum.EmailVerificationKindSignIn {+ expiresAt := time.Now().Add(5 * time.Minute)+ q.Result = &entity.EmailVerification{+ Key: q.Key,+ Kind: q.Kind,+ ExpiresAt: expiresAt,+ Email: "[email protected]",+ Name: "Hot Pie",+ }+ return nil+ }+ return app.ErrNotFound+ })++ var registeredUser *entity.User+ bus.AddHandler(func(ctx context.Context, c *cmd.RegisterUser) error {+ registeredUser = c.User+ registeredUser.ID = 1+ Expect(c.User.Name).Equals("Hot Pie")+ Expect(c.User.Email).Equals("[email protected]")+ Expect(c.User.Role).Equals(enum.RoleVisitor)+ return nil+ })++ bus.AddHandler(func(ctx context.Context, c *cmd.SetKeyAsVerified) error {+ return nil+ })++ server := mock.NewServer()++ code, response := server.+ OnTenant(mock.DemoTenant).+ WithURL("http://demo.test.fider.io/signin/verify?k=" + key).+ Execute(handlers.VerifySignInKey(enum.EmailVerificationKindSignIn))++ Expect(code).Equals(http.StatusTemporaryRedirect)+ Expect(response.Header().Get("Location")).Equals("http://demo.test.fider.io")+ Expect(registeredUser).IsNotNil()+ ExpectFiderAuthCookie(response, registeredUser)+}+func TestVerifySignInKeyHandler_PrivateTenant_SignInRequest_NonInviteNewUser(t *testing.T) {RegisterT(t)diff --git a/locale/ar/client.json b/locale/ar/client.jsonindex e6733320f..638761796 100644--- a/locale/ar/client.json+++ b/locale/ar/client.json@@ -14,6 +14,7 @@"action.respond": "رد","action.save": "احفظ","action.signin": "تسجيل الدخول",+ "action.signup": "","action.submit": "إرسال","action.vote": "صوت لهذه الفكرة","action.voted": "تم التصويت!",diff --git a/locale/de/client.json b/locale/de/client.jsonindex f03326c46..a2d68bbe7 100644--- a/locale/de/client.json+++ b/locale/de/client.json@@ -14,6 +14,7 @@"action.respond": "Antworten","action.save": "Sichern","action.signin": "Anmelden",+ "action.signup": "","action.submit": "Absenden","action.vote": "Abstimmen","action.voted": "Abgestimmt!",diff --git a/locale/el/client.json b/locale/el/client.jsonindex deeb85ea0..f6f90cdba 100644--- a/locale/el/client.json+++ b/locale/el/client.json@@ -14,6 +14,7 @@"action.respond": "Απάντηση","action.save": "Αποθήκευση","action.signin": "Είσοδος",+ "action.signup": "","action.submit": "Υποβολή","action.vote": "Ψηφίστε αυτήν την ιδέα","action.voted": "Ψηφίστηκε!",diff --git a/locale/es-ES/client.json b/locale/es-ES/client.jsonindex e87d9551a..2ae282314 100644--- a/locale/es-ES/client.json+++ b/locale/es-ES/client.json@@ -14,6 +14,7 @@"action.respond": "Responder","action.save": "Guardar","action.signin": "Iniciar sesión",+ "action.signup": "","action.submit": "Enviar","action.vote": "Vota por esta idea","action.voted": "¡Votado!",diff --git a/locale/fa/client.json b/locale/fa/client.jsonindex c00703d2d..f8e6848ca 100644--- a/locale/fa/client.json+++ b/locale/fa/client.json@@ -14,6 +14,7 @@"action.respond": "پاسخ","action.save": "ذخیره","action.signin": "ورود",+ "action.signup": "","action.submit": "ارسال","action.vote": "به این ایده رأی دهید","action.voted": "رأی داده شد!",diff --git a/locale/fr/client.json b/locale/fr/client.jsonindex b971a41ab..a1dbc55f7 100644--- a/locale/fr/client.json+++ b/locale/fr/client.json@@ -14,6 +14,7 @@"action.respond": "Répondre","action.save": "Enregistrer","action.signin": "Se connecter",+ "action.signup": "","action.submit": "Valider","action.vote": "Voter pour cette idée","action.voted": "Votée !",diff --git a/locale/it/client.json b/locale/it/client.jsonindex 2c998ad41..0c54c9b27 100644--- a/locale/it/client.json+++ b/locale/it/client.json@@ -14,6 +14,7 @@"action.respond": "Rispondi","action.save": "Salva","action.signin": "Accedi",+ "action.signup": "","action.submit": "Invia","action.vote": "Vota questa idea","action.voted": "Votato!",@@ -218,7 +219,6 @@"signin.message.private.text": "Se si dispone di un account o di un invito, è possibile utilizzare le seguenti opzioni per accedere.","signin.message.private.title": "<0>{0}</0> è uno spazio privato, è necessario registrarsi per partecipare e votare.","signin.message.socialbutton.intro": "Accedi con",- ""signin.name.placeholder": "","validation.custom.maxattachments": "Sono consentiti al massimo {number} allegati.","validation.custom.maximagesize": "La dimensione dell'immagine deve essere inferiore a {kilobytes}KB.",diff --git a/locale/ja/client.json b/locale/ja/client.jsonindex b8635ab28..e86e3765e 100644--- a/locale/ja/client.json+++ b/locale/ja/client.json@@ -14,6 +14,7 @@"action.respond": "回答","action.save": "保存","action.signin": "ログイン",+ "action.signup": "","action.submit": "送信","action.vote": "このアイデアに投票","action.voted": "投票完了!",diff --git a/locale/nl/client.json b/locale/nl/client.jsonindex 327aeb96d..106b044d2 100644--- a/locale/nl/client.json+++ b/locale/nl/client.json@@ -14,6 +14,7 @@"action.respond": "Reageren","action.save": "Opslaan","action.signin": "Inloggen",+ "action.signup": "","action.submit": "Verzenden","action.vote": "Stem op dit idee","action.voted": "Gestemd!",diff --git a/locale/pl/client.json b/locale/pl/client.jsonindex 1ea0df213..4d8a50183 100644--- a/locale/pl/client.json+++ b/locale/pl/client.json@@ -14,6 +14,7 @@"action.respond": "Odpowiedz","action.save": "Zapisz","action.signin": "Zaloguj się",+ "action.signup": "","action.submit": "Prześlij","action.vote": "Zagłosuj na ten pomysł","action.voted": "Zagłosowane!",diff --git a/locale/pt-BR/client.json b/locale/pt-BR/client.jsonindex a8440a802..00954f204 100644--- a/locale/pt-BR/client.json+++ b/locale/pt-BR/client.json@@ -14,6 +14,7 @@"action.respond": "Responder","action.save": "Salvar","action.signin": "Iniciar sessão",+ "action.signup": "","action.submit": "Enviar","action.vote": "Votar","action.voted": "Votado",diff --git a/locale/ru/client.json b/locale/ru/client.jsonindex 6bd38280f..321256ccc 100644--- a/locale/ru/client.json+++ b/locale/ru/client.json@@ -14,6 +14,7 @@"action.respond": "Ответить","action.save": "Сохранить","action.signin": "Войти",+ "action.signup": "","action.submit": "Продолжить","action.vote": "Проголосуйте за эту идею","action.voted": "Проголосовал!",diff --git a/locale/sk/client.json b/locale/sk/client.jsonindex 33572a28d..6bdf3fc4f 100644--- a/locale/sk/client.json+++ b/locale/sk/client.json@@ -14,6 +14,7 @@"action.respond": "Odpovedať","action.save": "Uložiť","action.signin": "Prihlásiť sa",+ "action.signup": "","action.submit": "Potvrdiť","action.vote": "Hlasovať za tento nápad","action.voted": "Zahlasované!",@@ -218,7 +219,6 @@"signin.message.private.text": "Ak máte účet alebo pozvánku, na prihlásenie môžete použiť nasledujúce možnosti.","signin.message.private.title": "<0>{0}</0> je súkromný priestor, ak sa chcete zúčastniť diskusie a hlasovať, musíte sa prihlásiť.","signin.message.socialbutton.intro": "Prihlásiť sa pomocou",- ""signin.name.placeholder": "","validation.custom.maxattachments": "Maximálny počet príloh je {number}.","validation.custom.maximagesize": "Veľkosť obrázka musí byť menšia ako {kilobytes}KB.",diff --git a/locale/sv-SE/client.json b/locale/sv-SE/client.jsonindex 16c827cdc..752f83f4e 100644--- a/locale/sv-SE/client.json+++ b/locale/sv-SE/client.json@@ -14,6 +14,7 @@"action.respond": "Svara","action.save": "Spara","action.signin": "Logga in",+ "action.signup": "","action.submit": "Skicka","action.vote": "Rösta på den här idén","action.voted": "Röstade!",diff --git a/locale/tr/client.json b/locale/tr/client.jsonindex c3e0fe467..fd6796b63 100644--- a/locale/tr/client.json+++ b/locale/tr/client.json@@ -14,6 +14,7 @@"action.respond": "Yanıtla","action.save": "Kaydet","action.signin": "Giriş Yap",+ "action.signup": "","action.submit": "Gönder","action.vote": "Bu fikre oy verin","action.voted": "Oy verildi!",diff --git a/locale/zh-CN/client.json b/locale/zh-CN/client.jsonindex 30f96f080..73740a6b4 100644--- a/locale/zh-CN/client.json+++ b/locale/zh-CN/client.json@@ -14,6 +14,7 @@"action.respond": "回复/标记","action.save": "保存","action.signin": "登录",+ "action.signup": "","action.submit": "提交","action.vote": "投票支持这个想法","action.voted": "已投票!",diff --git a/public/components/common/SignInControl.tsx b/public/components/common/SignInControl.tsxindex 894e458e7..b0b551ad8 100644--- a/public/components/common/SignInControl.tsx+++ b/public/components/common/SignInControl.tsx@@ -240,7 +240,7 @@ export const SignInControl: React.FunctionComponent<SignInControlProps> = (propsfunction renderCodeField(): React.ReactNode {return (<>- <p className="text-muted mb-2">+ <p className="text-muted mb-2 text-left"><Trans id="signin.code.instruction">Please type in the code we just sent to <strong>{email}</strong></Trans>{" "}@@ -267,7 +267,7 @@ export const SignInControl: React.FunctionComponent<SignInControlProps> = (props/></Form>{resendMessage && <p className="text-green-700 mt-2">{resendMessage}</p>}- <p className="text-center mt-2">+ <p className="text-center mt-2 text-muted text-left"><ahref="#"className="text-link"