Re-add password check, remove home_server from response

This commit is contained in:
Till Faelligen 2022-12-19 16:29:37 +01:00
parent f9a08db24d
commit a41a400c91
No known key found for this signature in database
GPG key ID: ACCDC9606D472758
3 changed files with 4 additions and 24 deletions

View file

@ -23,14 +23,12 @@ import (
"github.com/matrix-org/dendrite/clientapi/userutil"
"github.com/matrix-org/dendrite/setup/config"
userapi "github.com/matrix-org/dendrite/userapi/api"
"github.com/matrix-org/gomatrixserverlib"
"github.com/matrix-org/util"
)
type loginResponse struct {
UserID string `json:"user_id"`
AccessToken string `json:"access_token"`
HomeServer gomatrixserverlib.ServerName `json:"home_server"`
DeviceID string `json:"device_id"`
}
@ -116,7 +114,6 @@ func completeAuth(
JSON: loginResponse{
UserID: performRes.Device.UserID,
AccessToken: performRes.Device.AccessToken,
HomeServer: serverName,
DeviceID: performRes.Device.ID,
},
}

View file

@ -322,7 +322,7 @@ func validatePassword(password string) *util.JSONResponse {
Code: http.StatusBadRequest,
JSON: jsonerror.BadJSON(fmt.Sprintf("'password' >%d characters", maxPasswordLength)),
}
} else if len(password) < minPasswordLength {
} else if len(password) > 0 && len(password) < minPasswordLength {
return &util.JSONResponse{
Code: http.StatusBadRequest,
JSON: jsonerror.WeakPassword(fmt.Sprintf("password too weak: min %d chars", minPasswordLength)),

View file

@ -350,13 +350,6 @@ func Test_validatePassword(t *testing.T) {
password string
want *util.JSONResponse
}{
{
name: "no password supplied",
want: &util.JSONResponse{
Code: http.StatusBadRequest,
JSON: jsonerror.WeakPassword(fmt.Sprintf("password too weak: min %d chars", minPasswordLength)),
},
},
{
name: "password too short",
password: "shortpw",
@ -462,16 +455,6 @@ func Test_register(t *testing.T) {
JSON: jsonerror.InvalidUsername("Numeric user IDs are reserved"),
},
},
{
name: "can't register without password",
username: "helloworld",
password: "",
forceEmpty: true,
wantResponse: util.JSONResponse{
Code: http.StatusBadRequest,
JSON: jsonerror.WeakPassword(fmt.Sprintf("password too weak: min %d chars", minPasswordLength)),
},
},
}
test.WithAllDatabases(t, func(t *testing.T, dbType test.DBType) {