(w http.ResponseWriter, r *http.Request, user *identity.User, handoff *cliLoginHandoff)
| 244 | } |
| 245 | |
| 246 | func (ua *UserAuth) writeCLIHandoffPage(w http.ResponseWriter, r *http.Request, user *identity.User, handoff *cliLoginHandoff) error { |
| 247 | key, err := ua.store.CreateAPIKey(r.Context(), user.ID, "CLI login", nil) |
| 248 | if err != nil { |
| 249 | return fmt.Errorf("failed to create api key: %w", err) |
| 250 | } |
| 251 | |
| 252 | w.Header().Set("Content-Type", "text/html; charset=utf-8") |
| 253 | return cliLoginTemplate.Execute(w, map[string]string{ |
| 254 | "CallbackURL": handoff.CallbackURL, |
| 255 | "State": handoff.State, |
| 256 | "APIKey": key.PlaintextKey, |
| 257 | "AgentEmail": ua.defaultAgentEmail(r.Context(), user.ID), |
| 258 | }) |
| 259 | } |
| 260 | |
| 261 | // HandleLogin redirects the user to Google OAuth. |
| 262 | // CLI login params (cli_callback, cli_state) are encoded into the OAuth state |
no test coverage detected