+ {{/* these styles are quite tricky and should also apply to the signup and link_account pages */}}
{{template "user/auth/signin_inner" .}}
diff --git a/templates/user/auth/signup_inner.tmpl b/templates/user/auth/signup_inner.tmpl index b3b2a4205e..d66568199d 100644 --- a/templates/user/auth/signup_inner.tmpl +++ b/templates/user/auth/signup_inner.tmpl @@ -59,12 +59,12 @@
+ {{if not .LinkAccountMode}}
- {{if not .LinkAccountMode}}
{{ctx.Locale.Tr "auth.already_have_account"}} {{ctx.Locale.Tr "auth.sign_in_now"}}
- {{end}}
+ {{end}}
diff --git a/tests/integration/signin_test.go b/tests/integration/signin_test.go index d7c0b1bcd3..a76287ca94 100644 --- a/tests/integration/signin_test.go +++ b/tests/integration/signin_test.go @@ -15,8 +15,11 @@ import ( "code.gitea.io/gitea/modules/setting" "code.gitea.io/gitea/modules/test" "code.gitea.io/gitea/modules/translation" + "code.gitea.io/gitea/modules/web" + "code.gitea.io/gitea/services/context" "code.gitea.io/gitea/tests" + "github.com/markbates/goth" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) @@ -98,6 +101,11 @@ func TestSigninWithRememberMe(t *testing.T) { func TestEnablePasswordSignInForm(t *testing.T) { defer tests.PrepareTestEnv(t)() + mockLinkAccount := func(ctx *context.Context) { + gothUser := goth.User{Email: "invalid-email", Name: "."} + _ = ctx.Session.Set("linkAccountGothUser", gothUser) + } + t.Run("EnablePasswordSignInForm=false", func(t *testing.T) { defer tests.PrintCurrentTest(t)() defer test.MockVariableValue(&setting.Service.EnablePasswordSignInForm, false)() @@ -108,6 +116,12 @@ func TestEnablePasswordSignInForm(t *testing.T) { req = NewRequest(t, "POST", "/user/login") MakeRequest(t, req, http.StatusForbidden) + + req = NewRequest(t, "GET", "/user/link_account") + defer web.RouteMockReset() + web.RouteMock(web.MockAfterMiddlewares, mockLinkAccount) + resp = MakeRequest(t, req, http.StatusOK) + NewHTMLParser(t, resp.Body).AssertElement(t, "form[action='/user/link_account_signin']", false) }) t.Run("EnablePasswordSignInForm=true", func(t *testing.T) { @@ -120,5 +134,11 @@ func TestEnablePasswordSignInForm(t *testing.T) { req = NewRequest(t, "POST", "/user/login") MakeRequest(t, req, http.StatusOK) + + req = NewRequest(t, "GET", "/user/link_account") + defer web.RouteMockReset() + web.RouteMock(web.MockAfterMiddlewares, mockLinkAccount) + resp = MakeRequest(t, req, http.StatusOK) + NewHTMLParser(t, resp.Body).AssertElement(t, "form[action='/user/link_account_signin']", true) }) }