From d37b91f0705ce303cc2cab3d9da2e47b440e01a5 Mon Sep 17 00:00:00 2001 From: Tulir Asokan Date: Fri, 13 Dec 2024 16:29:48 +0200 Subject: [PATCH] legacyprovision: fix starting without existing login --- cmd/mautrix-gmessages/legacyprovision.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/cmd/mautrix-gmessages/legacyprovision.go b/cmd/mautrix-gmessages/legacyprovision.go index 2e4c2dd..3546d3f 100644 --- a/cmd/mautrix-gmessages/legacyprovision.go +++ b/cmd/mautrix-gmessages/legacyprovision.go @@ -302,7 +302,12 @@ func legacyProvGoogleLoginStart(w http.ResponseWriter, r *http.Request) { return } login := exerrors.Must(m.Connector.CreateLogin(r.Context(), user, connector.LoginFlowIDGoogle)) - nextStep := exerrors.Must(login.(bridgev2.LoginProcessWithOverride).StartWithOverride(r.Context(), existingLogin)) + var nextStep *bridgev2.LoginStep + if existingLogin != nil { + nextStep = exerrors.Must(login.(bridgev2.LoginProcessWithOverride).StartWithOverride(r.Context(), existingLogin)) + } else { + nextStep = exerrors.Must(login.Start(r.Context())) + } if nextStep.StepID != connector.LoginStepIDGoogle { log.Warn().Str("step_id", nextStep.StepID).Msg("Unexpected step after starting login") jsonResponse(w, http.StatusInternalServerError, Error{