runLoginFlowPreflightChecks checks if we need to make any updates to the client being tested in order to log in successfully. If so, it asks the user to confirm whether to proceed.
(cli *cli, c *management.Client)
| 140 | // to the client being tested in order to log in successfully. |
| 141 | // If so, it asks the user to confirm whether to proceed. |
| 142 | func runLoginFlowPreflightChecks(cli *cli, c *management.Client) (abort bool) { |
| 143 | if !cli.noInput { |
| 144 | cli.renderer.Infof("A browser window needs to be opened to complete this client's login flow.") |
| 145 | cli.renderer.Infof("Once login is complete, you can return to the CLI to view user profile information and tokens.") |
| 146 | cli.renderer.Newline() |
| 147 | } |
| 148 | |
| 149 | // Check if the chosen client includes our local callback URL in its allowed list. |
| 150 | // If not we'll need to add it (after asking the user for permission). |
| 151 | if !hasLocalCallbackURL(c) { |
| 152 | cli.renderer.Warnf("The client you are using does not currently allow callbacks to localhost.") |
| 153 | cli.renderer.Warnf("To complete the login flow the CLI needs to redirect logins to a local server and record the result.\n") |
| 154 | cli.renderer.Warnf("The client will be modified to update the allowed callback URLs, we'll remove them when done.") |
| 155 | cli.renderer.Warnf("If you do not wish to modify the client, you can abort now.") |
| 156 | cli.renderer.Newline() |
| 157 | } |
| 158 | |
| 159 | if !cli.force && !cli.noInput { |
| 160 | if confirmed := prompt.Confirm("Do you wish to proceed?"); !confirmed { |
| 161 | return false |
| 162 | } |
| 163 | } |
| 164 | |
| 165 | cli.renderer.Newline() |
| 166 | |
| 167 | return true |
| 168 | } |
| 169 | |
| 170 | // runLoginFlow initiates a full user-facing login flow, waits for a response |
| 171 | // and returns the retrieved tokens to the caller when done. |
no test coverage detected