mirror of
https://github.com/matrix-org/dendrite.git
synced 2025-12-15 10:53:09 -06:00
Fix completeRegistration func definition
This commit is contained in:
parent
1333cacb4c
commit
37cab577ef
|
|
@ -16,6 +16,7 @@
|
||||||
package routing
|
package routing
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"crypto/hmac"
|
"crypto/hmac"
|
||||||
"crypto/sha1"
|
"crypto/sha1"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
|
@ -555,7 +556,7 @@ func handleRegistrationFlow(
|
||||||
// Don't need to worry about appending to registration stages as
|
// Don't need to worry about appending to registration stages as
|
||||||
// application service registration is entirely separate.
|
// application service registration is entirely separate.
|
||||||
return completeRegistration(
|
return completeRegistration(
|
||||||
req, accountDB, deviceDB, r.Username, "", appserviceID,
|
req.Context(), accountDB, deviceDB, r.Username, "", appserviceID,
|
||||||
r.InhibitLogin, r.InitialDisplayName,
|
r.InhibitLogin, r.InitialDisplayName,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -593,7 +594,7 @@ func checkAndCompleteFlow(
|
||||||
if checkFlowCompleted(flow, cfg.Derived.Registration.Flows) {
|
if checkFlowCompleted(flow, cfg.Derived.Registration.Flows) {
|
||||||
// This flow was completed, registration can continue
|
// This flow was completed, registration can continue
|
||||||
return completeRegistration(
|
return completeRegistration(
|
||||||
req, accountDB, deviceDB, r.Username, r.Password, "",
|
req.Context(), accountDB, deviceDB, r.Username, r.Password, "",
|
||||||
r.InhibitLogin, r.InitialDisplayName,
|
r.InhibitLogin, r.InitialDisplayName,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
@ -645,10 +646,10 @@ func LegacyRegister(
|
||||||
return util.MessageResponse(http.StatusForbidden, "HMAC incorrect")
|
return util.MessageResponse(http.StatusForbidden, "HMAC incorrect")
|
||||||
}
|
}
|
||||||
|
|
||||||
return completeRegistration(req, accountDB, deviceDB, r.Username, r.Password, "", 0, nil)
|
return completeRegistration(req.Context(), accountDB, deviceDB, r.Username, r.Password, "", 0, nil)
|
||||||
case authtypes.LoginTypeDummy:
|
case authtypes.LoginTypeDummy:
|
||||||
// there is nothing to do
|
// there is nothing to do
|
||||||
return completeRegistration(req, accountDB, deviceDB, r.Username, r.Password, "", 0, nil)
|
return completeRegistration(req.Context(), accountDB, deviceDB, r.Username, r.Password, "", 0, nil)
|
||||||
default:
|
default:
|
||||||
return util.JSONResponse{
|
return util.JSONResponse{
|
||||||
Code: http.StatusNotImplemented,
|
Code: http.StatusNotImplemented,
|
||||||
|
|
@ -687,11 +688,12 @@ func parseAndValidateLegacyLogin(req *http.Request, r *legacyRegisterRequest) *u
|
||||||
}
|
}
|
||||||
|
|
||||||
func completeRegistration(
|
func completeRegistration(
|
||||||
req *http.Request,
|
ctx context.Context,
|
||||||
accountDB *accounts.Database,
|
accountDB *accounts.Database,
|
||||||
deviceDB *devices.Database,
|
deviceDB *devices.Database,
|
||||||
username, password, appserviceID string,
|
username, password, appserviceID string,
|
||||||
inhibitLogin int, displayName *string,
|
inhibitLogin int,
|
||||||
|
displayName *string,
|
||||||
) util.JSONResponse {
|
) util.JSONResponse {
|
||||||
if username == "" {
|
if username == "" {
|
||||||
return util.JSONResponse{
|
return util.JSONResponse{
|
||||||
|
|
@ -707,7 +709,7 @@ func completeRegistration(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
acc, err := accountDB.CreateAccount(req.Context(), username, password, appserviceID)
|
acc, err := accountDB.CreateAccount(ctx, username, password, appserviceID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return util.JSONResponse{
|
return util.JSONResponse{
|
||||||
Code: http.StatusInternalServerError,
|
Code: http.StatusInternalServerError,
|
||||||
|
|
@ -741,7 +743,7 @@ func completeRegistration(
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Use the device ID in the request.
|
// TODO: Use the device ID in the request.
|
||||||
dev, err := deviceDB.CreateDevice(req.Context(), username, nil, token, displayName)
|
dev, err := deviceDB.CreateDevice(ctx, username, nil, token, displayName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return util.JSONResponse{
|
return util.JSONResponse{
|
||||||
Code: http.StatusInternalServerError,
|
Code: http.StatusInternalServerError,
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue