mirror of
https://github.com/drakkan/sftpgo.git
synced 2025-12-08 15:28:05 +03:00
web client login: redirect to setup page if no admin is found
This commit is contained in:
@@ -5944,6 +5944,11 @@ func TestWebAdminSetupMock(t *testing.T) {
|
|||||||
rr = executeRequest(req)
|
rr = executeRequest(req)
|
||||||
checkResponseCode(t, http.StatusFound, rr)
|
checkResponseCode(t, http.StatusFound, rr)
|
||||||
assert.Equal(t, webAdminSetupPath, rr.Header().Get("Location"))
|
assert.Equal(t, webAdminSetupPath, rr.Header().Get("Location"))
|
||||||
|
req, err = http.NewRequest(http.MethodGet, webClientLoginPath, nil)
|
||||||
|
assert.NoError(t, err)
|
||||||
|
rr = executeRequest(req)
|
||||||
|
checkResponseCode(t, http.StatusFound, rr)
|
||||||
|
assert.Equal(t, webAdminSetupPath, rr.Header().Get("Location"))
|
||||||
|
|
||||||
csrfToken, err := getCSRFToken(httpBaseURL + webAdminSetupPath)
|
csrfToken, err := getCSRFToken(httpBaseURL + webAdminSetupPath)
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
|
|||||||
@@ -253,6 +253,10 @@ func renderCredentialsPage(w http.ResponseWriter, r *http.Request, pwdError stri
|
|||||||
}
|
}
|
||||||
|
|
||||||
func handleClientWebLogin(w http.ResponseWriter, r *http.Request) {
|
func handleClientWebLogin(w http.ResponseWriter, r *http.Request) {
|
||||||
|
if !dataprovider.HasAdmin() {
|
||||||
|
http.Redirect(w, r, webAdminSetupPath, http.StatusFound)
|
||||||
|
return
|
||||||
|
}
|
||||||
renderClientLoginPage(w, "")
|
renderClientLoginPage(w, "")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user