diff --git a/clientapi/auth/authtypes/stages.go b/clientapi/auth/authtypes/stages.go index 49024504c..34b74444a 100644 --- a/clientapi/auth/authtypes/stages.go +++ b/clientapi/auth/authtypes/stages.go @@ -15,5 +15,5 @@ package authtypes const ( - LoginStagePublicKeyNewSession = "m.login.publickey.newsession" + LoginStagePublicKeyNewRegistration = "m.login.publickey.newregistration" ) diff --git a/clientapi/auth/login_publickey_ethereum.go b/clientapi/auth/login_publickey_ethereum.go index 3ac367a81..a3201a269 100644 --- a/clientapi/auth/login_publickey_ethereum.go +++ b/clientapi/auth/login_publickey_ethereum.go @@ -135,7 +135,7 @@ func (pk LoginPublicKeyEthereum) ValidateLoginResponse() (bool, *jsonerror.Matri func (pk LoginPublicKeyEthereum) CreateLogin() *Login { identifier := LoginIdentifier{ - Type: "m.id.publickey", + Type: "m.id.decentralizedid", User: pk.UserId, } login := Login{ diff --git a/clientapi/auth/user_interactive.go b/clientapi/auth/user_interactive.go index ff7d2ed90..4dbf23320 100644 --- a/clientapi/auth/user_interactive.go +++ b/clientapi/auth/user_interactive.go @@ -75,7 +75,7 @@ type Login struct { // Username returns the user localpart/user_id in this request, if it exists. func (r *Login) Username() string { - if r.Identifier.Type == "m.id.user" || r.Identifier.Type == "m.id.publickey" { + if r.Identifier.Type == "m.id.user" || r.Identifier.Type == "m.id.decentralizedid" { return r.Identifier.User } // deprecated but without it Element iOS won't log in diff --git a/clientapi/routing/register.go b/clientapi/routing/register.go index 55bb0df87..f8fa0dad3 100644 --- a/clientapi/routing/register.go +++ b/clientapi/routing/register.go @@ -750,8 +750,8 @@ func handleRegistrationFlow( } } - switch true { - case r.Auth.Type == authtypes.LoginTypeRecaptcha: + switch r.Auth.Type { + case authtypes.LoginTypeRecaptcha: // Check given captcha response resErr := validateRecaptcha(cfg, r.Auth.Response, req.RemoteAddr) if resErr != nil { @@ -761,12 +761,14 @@ func handleRegistrationFlow( // Add Recaptcha to the list of completed registration stages sessions.addCompletedSessionStage(sessionID, authtypes.LoginTypeRecaptcha) - case r.Auth.Type == authtypes.LoginTypeDummy && !cfg.PasswordAuthenticationDisabled: + case authtypes.LoginTypeDummy: // there is nothing to do // Add Dummy to the list of completed registration stages - sessions.addCompletedSessionStage(sessionID, authtypes.LoginTypeDummy) + if !cfg.PasswordAuthenticationDisabled { + sessions.addCompletedSessionStage(sessionID, authtypes.LoginTypeDummy) + } - case r.Auth.Type == authtypes.LoginTypePublicKey: + case authtypes.LoginTypePublicKey: _, authType, err := handlePublicKeyRegistration(cfg, reqBody, &r, userAPI) if err != nil { return *err @@ -774,7 +776,7 @@ func handleRegistrationFlow( sessions.addCompletedSessionStage(sessionID, authType) - case r.Auth.Type == "": + case "": // An empty auth type means that we want to fetch the available // flows. It can also mean that we want to register as an appservice // but that is handed above. diff --git a/clientapi/routing/register_publickey.go b/clientapi/routing/register_publickey.go index 6132530d0..258a47249 100644 --- a/clientapi/routing/register_publickey.go +++ b/clientapi/routing/register_publickey.go @@ -59,7 +59,7 @@ func handlePublicKeyRegistration( authHandler = pkEthHandler default: // No response. Client is asking for a new registration session - return false, authtypes.LoginStagePublicKeyNewSession, nil + return false, authtypes.LoginStagePublicKeyNewRegistration, nil } if _, ok := sessions.sessions[authHandler.GetSession()]; !ok {