Skip to content

Commit 42e5824

Browse files
committed
session is optional and may be omitted if not provided
Signed-off-by: timedout <git@nexy7574.co.uk>
1 parent 96ac074 commit 42e5824

2 files changed

Lines changed: 5 additions & 5 deletions

File tree

client/auth.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -118,15 +118,15 @@ func (c *CSAPI) RegisterUser(t ct.TestLike, localpart, password string) (userID,
118118
ct.Fatalf(t, "unable to read response body: %v", err)
119119
}
120120
session := GetJSONFieldStr(t, body, "session")
121-
if session == "" {
122-
ct.Fatalf(t, "uia challenge did not include a session")
123-
}
124121

125122
// Now actually register the user
126123
reqBody["auth"] = map[string]any{
127124
"session": session,
128125
"type": "m.login.dummy",
129126
}
127+
if session == "" {
128+
delete(reqBody["auth"].(map[string]any), "session")
129+
}
130130
res = c.MustDo(t, "POST", []string{"_matrix", "client", "v3", "register"}, WithJSONBody(t, reqBody))
131131
body, err = io.ReadAll(res.Body)
132132
if err != nil {

tests/csapi/apidoc_register_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -344,9 +344,9 @@ func startUIASession(t *testing.T, c *client.CSAPI, user, pass string, extra map
344344
t.Fatal(err)
345345
}
346346
session := client.GetJSONFieldStr(t, body, "session")
347+
reqBody["auth"] = map[string]string{"session": session, "type": "m.login.dummy"}
347348
if session == "" {
348-
t.Fatal("expected non-empty `session` in uia challenge")
349+
delete(reqBody["auth"].(map[string]any), "session")
349350
}
350-
reqBody["auth"] = map[string]string{"session": session, "type": "m.login.dummy"}
351351
return reqBody, session
352352
}

0 commit comments

Comments
 (0)