rename user id to decentralizedid

This commit is contained in:
Tak Wai Wong 2022-06-30 15:10:16 -07:00
parent cebc4ec489
commit 7d1678d688
5 changed files with 12 additions and 10 deletions

View file

@ -15,5 +15,5 @@
package authtypes package authtypes
const ( const (
LoginStagePublicKeyNewSession = "m.login.publickey.newsession" LoginStagePublicKeyNewRegistration = "m.login.publickey.newregistration"
) )

View file

@ -135,7 +135,7 @@ func (pk LoginPublicKeyEthereum) ValidateLoginResponse() (bool, *jsonerror.Matri
func (pk LoginPublicKeyEthereum) CreateLogin() *Login { func (pk LoginPublicKeyEthereum) CreateLogin() *Login {
identifier := LoginIdentifier{ identifier := LoginIdentifier{
Type: "m.id.publickey", Type: "m.id.decentralizedid",
User: pk.UserId, User: pk.UserId,
} }
login := Login{ login := Login{

View file

@ -75,7 +75,7 @@ type Login struct {
// Username returns the user localpart/user_id in this request, if it exists. // Username returns the user localpart/user_id in this request, if it exists.
func (r *Login) Username() string { 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 return r.Identifier.User
} }
// deprecated but without it Element iOS won't log in // deprecated but without it Element iOS won't log in

View file

@ -750,8 +750,8 @@ func handleRegistrationFlow(
} }
} }
switch true { switch r.Auth.Type {
case r.Auth.Type == authtypes.LoginTypeRecaptcha: case authtypes.LoginTypeRecaptcha:
// Check given captcha response // Check given captcha response
resErr := validateRecaptcha(cfg, r.Auth.Response, req.RemoteAddr) resErr := validateRecaptcha(cfg, r.Auth.Response, req.RemoteAddr)
if resErr != nil { if resErr != nil {
@ -761,12 +761,14 @@ func handleRegistrationFlow(
// Add Recaptcha to the list of completed registration stages // Add Recaptcha to the list of completed registration stages
sessions.addCompletedSessionStage(sessionID, authtypes.LoginTypeRecaptcha) sessions.addCompletedSessionStage(sessionID, authtypes.LoginTypeRecaptcha)
case r.Auth.Type == authtypes.LoginTypeDummy && !cfg.PasswordAuthenticationDisabled: case authtypes.LoginTypeDummy:
// there is nothing to do // there is nothing to do
// Add Dummy to the list of completed registration stages // 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) _, authType, err := handlePublicKeyRegistration(cfg, reqBody, &r, userAPI)
if err != nil { if err != nil {
return *err return *err
@ -774,7 +776,7 @@ func handleRegistrationFlow(
sessions.addCompletedSessionStage(sessionID, authType) sessions.addCompletedSessionStage(sessionID, authType)
case r.Auth.Type == "": case "":
// An empty auth type means that we want to fetch the available // 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 // flows. It can also mean that we want to register as an appservice
// but that is handed above. // but that is handed above.

View file

@ -59,7 +59,7 @@ func handlePublicKeyRegistration(
authHandler = pkEthHandler authHandler = pkEthHandler
default: default:
// No response. Client is asking for a new registration session // 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 { if _, ok := sessions.sessions[authHandler.GetSession()]; !ok {