(c flags.FlagContext)
| 82 | } |
| 83 | |
| 84 | func (cmd *Login) Execute(c flags.FlagContext) error { |
| 85 | cmd.config.ClearSession() |
| 86 | |
| 87 | endpoint, skipSSL := cmd.decideEndpoint(c) |
| 88 | |
| 89 | api := API{ |
| 90 | ui: cmd.ui, |
| 91 | config: cmd.config, |
| 92 | endpointRepo: cmd.endpointRepo, |
| 93 | } |
| 94 | err := api.setAPIEndpoint(endpoint, skipSSL, cmd.MetaData().Name) |
| 95 | if err != nil { |
| 96 | return err |
| 97 | } |
| 98 | |
| 99 | err = command.MinimumCCAPIVersionCheck(cmd.config.APIVersion(), ccversion.MinSupportedV2ClientVersion) |
| 100 | if err != nil { |
| 101 | if _, ok := err.(translatableerror.MinimumCFAPIVersionNotMetError); ok { |
| 102 | cmd.ui.Warn("Your API version is no longer supported. Upgrade to a newer version of the API.") |
| 103 | } else { |
| 104 | return err |
| 105 | } |
| 106 | } |
| 107 | |
| 108 | defer func() { |
| 109 | cmd.ui.Say("") |
| 110 | cmd.ui.ShowConfiguration(cmd.config) |
| 111 | }() |
| 112 | |
| 113 | // We thought we would never need to explicitly branch in this code |
| 114 | // for anything as simple as authentication, but it turns out that our |
| 115 | // assumptions did not match reality. |
| 116 | |
| 117 | // When SAML is enabled (but not configured) then the UAA/Login server |
| 118 | // will always returns password prompts that includes the Passcode field. |
| 119 | // Users can authenticate with: |
| 120 | // EITHER username and password |
| 121 | // OR a one-time passcode |
| 122 | |
| 123 | switch { |
| 124 | case c.Bool("sso") && c.IsSet("sso-passcode"): |
| 125 | return errors.New(T("Incorrect usage: --sso-passcode flag cannot be used with --sso")) |
| 126 | case c.Bool("sso") || c.IsSet("sso-passcode"): |
| 127 | err = cmd.authenticateSSO(c) |
| 128 | if err != nil { |
| 129 | return err |
| 130 | } |
| 131 | default: |
| 132 | err = cmd.authenticate(c) |
| 133 | if err != nil { |
| 134 | return err |
| 135 | } |
| 136 | } |
| 137 | |
| 138 | orgIsSet, err := cmd.setOrganization(c) |
| 139 | if err != nil { |
| 140 | return err |
| 141 | } |
nothing calls this directly
no test coverage detected