Add hint for using SSO

This commit is contained in:
Tulir Asokan 2022-11-07 18:39:06 +02:00
parent 99a5c7caed
commit c741634733

View File

@ -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 {
} 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")
}