mirror of
https://github.com/matrix-org/dendrite.git
synced 2026-01-22 05:23:09 -06:00
Re-add password check, remove home_server from response
This commit is contained in:
parent
f9a08db24d
commit
a41a400c91
|
|
@ -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,
|
||||
},
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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)),
|
||||
|
|
|
|||
|
|
@ -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) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue