1
1
mirror of https://github.com/go-gitea/gitea synced 2025-07-05 10:07:22 +00:00

Make "/user/login" page redirect if the current user has signed in (#29583) (#29599)

Backport #29583
This commit is contained in:
wxiaoguang
2024-03-05 21:03:45 +08:00
committed by GitHub
parent 4ef7e496b8
commit 02df269d24
4 changed files with 65 additions and 12 deletions

View File

@ -7,6 +7,7 @@ package contexttest
import (
gocontext "context"
"io"
"maps"
"net/http"
"net/http/httptest"
"net/url"
@ -36,7 +37,7 @@ func mockRequest(t *testing.T, reqPath string) *http.Request {
}
requestURL, err := url.Parse(path)
assert.NoError(t, err)
req := &http.Request{Method: method, URL: requestURL, Form: url.Values{}}
req := &http.Request{Method: method, URL: requestURL, Form: maps.Clone(requestURL.Query()), Header: http.Header{}}
req = req.WithContext(middleware.WithContextData(req.Context()))
return req
}