diff --git a/README.md b/README.md index e0ccc99..ef07ab1 100644 --- a/README.md +++ b/README.md @@ -32,8 +32,7 @@ for machine-readable output: `{"url": …, "confirmation_code": …, "status": " The credential refreshes itself; `frbit auth status` shows its expiry and the next setup step. -`--signup` opens the sign-up page, for people without an account. -`--name ""` suggests the name for the new account (1 to 100 characters). +`--name ""` suggests the name for a new account (1 to 100 characters). In CI or without a browser, store a personal API token from standard input: diff --git a/docs/cli.md b/docs/cli.md index 7134a61..f26e435 100644 --- a/docs/cli.md +++ b/docs/cli.md @@ -67,12 +67,11 @@ The command prints the sign-in URL and a code first, opens the URL in your defau |--|--| | `--no-browser` | Print the URL without opening a browser | | `--json` | Print `{"url": …, "confirmation_code": …, "status": "waiting"}` at once, then `{"status": "signed_in", "next": …}` | -| `--signup` | Open the sign-up page instead of the login page, for people without an account | -| `--name ""` | Suggest a name for the new account, 1 to 100 characters | +| `--name ""` | Suggest a name for a new account, 1 to 100 characters | If the person denies the consent request, the browser tab shows "Not connected. Your agent knows; you can close this tab." and the command fails. With `--json` the last line is `{"status": "error", "code": "access_denied", "error": …}`. The consent request is used up, so ask the person before running `frbit auth login` again. Other stable codes: `timeout` and `frbit_token_set`. -Coding agents run `frbit auth login --json` in the background, show the URL to the person, and continue with `next`. For a person without an account they add `--signup`. +Coding agents run `frbit auth login --json` in the background, show the URL to the person, and continue with `next`. Verify the active credential at any time. It shows the profile, host, credential kind, expiry, and the next setup step. With `--json` it prints one line with `"status": "signed_in"` and the same fields, `{"status": "signed_out"}` (exit 0) without a credential, or `{"status": "error", "error": …}` (exit 1): @@ -879,12 +878,13 @@ Behaviour that changed since v1.14.0 and can break a script: | A path argument with `.` or `..` segments was sent as is | The CLI refuses it before any request | | `environments list` printed `ID NAME SOFTWARE UPDATED` | It prints `ID APP NAME UPDATED`; `--json` is unchanged | | A command with nothing linked failed with `no environment for this checkout; …` only | Without a terminal, the environments of the account follow on the next lines; on a terminal it asks | +| `auth login --signup` opened the sign-up page | The flag is gone and fails as unknown: the sign-in page also creates accounts | ## Command reference | Command | Description | | --- | --- | -| `frbit auth login` | Sign in through the browser. Accepts `--no-browser`, `--json`, `--signup`, `--name`, and `--token-stdin` for a personal API token. | +| `frbit auth login` | Sign in through the browser. Accepts `--no-browser`, `--json`, `--name`, and `--token-stdin` for a personal API token. | | `frbit auth status` | Validate the credential selected by `--profile` or `FRBIT_TOKEN` and show its kind, expiry, and the next setup step. Accepts `--json`. | | `frbit auth logout` | Revoke a browser sign-in and remove the stored credential for the selected profile. | | `frbit apps list` | List apps. Accepts `--page`, `--limit`, `--all`, repeatable `--id`, and `--json`. | diff --git a/internal/cmd/auth/login/login.go b/internal/cmd/auth/login/login.go index 9e02bb9..92db99e 100644 --- a/internal/cmd/auth/login/login.go +++ b/internal/cmd/auth/login/login.go @@ -28,7 +28,6 @@ type Options struct { TokenStdin bool NoBrowser bool JSON bool - Signup bool Name string Timeout time.Duration } @@ -48,8 +47,7 @@ In CI or without a browser, pipe a personal API token to --token-stdin, or set FRBIT_TOKEN for each command instead of signing in. With FRBIT_TOKEN set, login refuses to start, since FRBIT_TOKEN overrides any stored credential. -Use --signup when the person has no fortrabbit account yet: the browser opens the -sign-up page instead of the login page. --name suggests the name for the new +The sign-in page also creates accounts. --name suggests the name for a new account (1 to 100 characters); pass only a name the person gave you or their git user.name. With --json, a failure prints {"status": "error", "code": …, "error": …}. The code is @@ -65,7 +63,7 @@ func NewCmdLogin(factory *app.Factory, runF func(*Options) error) *cobra.Command Long: longHelp, Example: ` frbit auth login frbit auth login --json - frbit auth login --signup --name "Ada Lovelace" + frbit auth login --name "Ada Lovelace" printf '%s' "$TOKEN" | frbit auth login --token-stdin`, Args: cobra.NoArgs, RunE: func(cmd *cobra.Command, args []string) error { @@ -79,7 +77,6 @@ func NewCmdLogin(factory *app.Factory, runF func(*Options) error) *cobra.Command command.Flags().BoolVar(&options.TokenStdin, "token-stdin", false, "Read a personal API token from standard input instead of signing in") command.Flags().BoolVar(&options.NoBrowser, "no-browser", false, "Print the sign-in URL without opening a browser") command.Flags().BoolVar(&options.JSON, "json", false, "Print the sign-in URL, the confirmation code and the result as JSON lines") - command.Flags().BoolVar(&options.Signup, "signup", false, "Open the sign-up page, for people without an account") command.Flags().StringVar(&options.Name, "name", "", "Suggest a name for the new account") return command } @@ -141,7 +138,7 @@ func runBrowser(options *Options) error { } out := command.OutOrStdout() - loginOptions := oauth.Options{Signup: options.Signup, NameHint: options.Name, Host: host, DashboardURL: dashboardURL, Out: out, Timeout: options.Timeout, HTTPClient: options.Factory.HTTPClient} + loginOptions := oauth.Options{NameHint: options.Name, Host: host, DashboardURL: dashboardURL, Out: out, Timeout: options.Timeout, HTTPClient: options.Factory.HTTPClient} if !options.NoBrowser { loginOptions.OpenBrowser = options.Factory.OpenBrowser } diff --git a/internal/cmd/auth/login/login_test.go b/internal/cmd/auth/login/login_test.go index 309799c..b964e7e 100644 --- a/internal/cmd/auth/login/login_test.go +++ b/internal/cmd/auth/login/login_test.go @@ -461,7 +461,7 @@ func TestLoginJSONLinesAreNotEscaped(t *testing.T) { } } -func TestLoginSignupAndNameReachTheAuthorizeURL(t *testing.T) { +func TestLoginNameReachesTheAuthorizeURL(t *testing.T) { cases := []struct { extra []string noBrowser bool @@ -469,7 +469,7 @@ func TestLoginSignupAndNameReachTheAuthorizeURL(t *testing.T) { for _, tc := range cases { fake := newFakeAPI(t) factory, _, _ := loginFactory(t, fake) - args := append([]string{"--signup", "--name", "Ada Lovelace & Co"}, tc.extra...) + args := append([]string{"--name", "Ada Lovelace & Co"}, tc.extra...) var err error if tc.noBrowser { writer := &urlWriter{onURL: fake.approve(t)} @@ -491,13 +491,13 @@ func TestLoginSignupAndNameReachTheAuthorizeURL(t *testing.T) { fake.mu.Lock() query := fake.authorize fake.mu.Unlock() - if query.Get("prompt") != "create" || query.Get("name_hint") != "Ada Lovelace & Co" { + if query.Has("prompt") || query.Get("name_hint") != "Ada Lovelace & Co" { t.Fatalf("login %v authorize query = %v", args, query) } } } -func TestLoginWithoutSignupSendsNeitherParameter(t *testing.T) { +func TestLoginWithoutNameSendsNeitherParameter(t *testing.T) { fake := newFakeAPI(t) factory, _, _ := loginFactory(t, fake) if _, err := executeLogin(t, factory, fake.URL); err != nil { @@ -515,7 +515,7 @@ func TestLoginRejectsInvalidNameBeforeOpeningTheBrowser(t *testing.T) { fake := newFakeAPI(t) factory, _, _ := loginFactory(t, fake) factory.OpenBrowser = func(string) error { t.Error("browser opened for an invalid name"); return nil } - output, err := executeLogin(t, factory, fake.URL, "--signup", "--name", name, "--json") + output, err := executeLogin(t, factory, fake.URL, "--name", name, "--json") if err == nil || !strings.Contains(err.Error(), "--name") { t.Fatalf("name %q: error = %v", name, err) } diff --git a/internal/oauth/flow.go b/internal/oauth/flow.go index 7efc340..4509b93 100644 --- a/internal/oauth/flow.go +++ b/internal/oauth/flow.go @@ -43,8 +43,6 @@ type Options struct { HTTPClient *http.Client // OnURL replaces the default sign-in prompt on Out, for machine-readable output. It gets the URL and the confirmation code. OnURL func(authorizeURL string, confirmationCode string) error - // Signup sends prompt=create, so a person without an account lands on the sign-up page. - Signup bool // NameHint suggests the name for a new account, sent as name_hint. NameHint string } @@ -422,9 +420,6 @@ func (m serverMetadata) authorizeURL(redirectURI string, challenge string, confi query.Set("code_challenge_method", "S256") query.Set("state", state) query.Set("confirmation_challenge", confirmation) - if options.Signup { - query.Set("prompt", "create") - } if options.NameHint != "" { query.Set("name_hint", options.NameHint) } diff --git a/internal/oauth/flow_test.go b/internal/oauth/flow_test.go index 4011bfa..2981513 100644 --- a/internal/oauth/flow_test.go +++ b/internal/oauth/flow_test.go @@ -556,17 +556,14 @@ func TestHumanDuration(t *testing.T) { } } -func TestLoginAuthorizeURLCarriesSignupAndNameHint(t *testing.T) { +func TestLoginAuthorizeURLCarriesNameHint(t *testing.T) { cases := []struct { name string options Options - prompt string hint string }{ - {"plain", Options{}, "", ""}, - {"signup", Options{Signup: true}, "create", ""}, - {"name", Options{NameHint: "Ada Lovelace"}, "", "Ada Lovelace"}, - {"both", Options{Signup: true, NameHint: "Ada & Co"}, "create", "Ada & Co"}, + {"plain", Options{}, ""}, + {"name", Options{NameHint: "Ada & Co"}, "Ada & Co"}, } for _, tc := range cases { t.Run(tc.name, func(t *testing.T) { @@ -584,7 +581,7 @@ func TestLoginAuthorizeURLCarriesSignupAndNameHint(t *testing.T) { t.Fatal(err) } query := authorize.Query() - if query.Get("prompt") != tc.prompt || query.Get("name_hint") != tc.hint || query.Has("prompt") != (tc.prompt != "") || query.Has("name_hint") != (tc.hint != "") { + if query.Has("prompt") || query.Get("name_hint") != tc.hint || query.Has("name_hint") != (tc.hint != "") { t.Fatalf("query = %v", query) } })