From c74163473346e316bf4594ad09581bc5f86cebd8 Mon Sep 17 00:00:00 2001 From: Tulir Asokan Date: Mon, 7 Nov 2022 18:39:06 +0200 Subject: [PATCH] Add hint for using SSO --- matrix/matrix.go | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/matrix/matrix.go b/matrix/matrix.go index a8397d1..b488600 100644 --- a/matrix/matrix.go +++ b/matrix/matrix.go @@ -256,13 +256,21 @@ func (c *Container) Login(user, password string) error { if err != nil { return err } + ssoSkippedBecausePassword := false for _, flow := range resp.Flows { if flow.Type == "m.login.password" { return c.PasswordLogin(user, password) - } else if flow.Type == "m.login.sso" && len(password) == 0 { - return c.SingleSignOn() + } else if flow.Type == "m.login.sso" { + if len(password) == 0 { + return c.SingleSignOn() + } else { + ssoSkippedBecausePassword = true + } } } + if ssoSkippedBecausePassword { + return fmt.Errorf("password login is not supported\nleave the password field blank to use SSO") + } return fmt.Errorf("no supported login flows") }