Skip to content

feat: generate a new session with coder login --token #8275

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Jul 5, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
flag to enable previous behavior if needed
  • Loading branch information
Emyrk committed Jun 30, 2023
commit cff7859039f1b6694093cd78df1a8ad2e9245b88
16 changes: 11 additions & 5 deletions cli/login.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,11 @@ func (r *RootCmd) login() *clibase.Cmd {
const firstUserTrialEnv = "CODER_FIRST_USER_TRIAL"

var (
email string
username string
password string
trial bool
email string
username string
password string
trial bool
useTokenForSession bool
)
cmd := &clibase.Cmd{
Use: "login <url>",
Expand Down Expand Up @@ -246,7 +247,7 @@ func (r *RootCmd) login() *clibase.Cmd {
if err != nil {
return xerrors.Errorf("paste token prompt: %w", err)
}
} else {
} else if !useTokenForSession {
// If a session token is provided on the cli, use it to generate
// a new one. This is because the cli `--token` flag provides
// a token for the command being invoked. We should not store
Expand Down Expand Up @@ -310,6 +311,11 @@ func (r *RootCmd) login() *clibase.Cmd {
Description: "Specifies whether a trial license should be provisioned for the Coder deployment or not.",
Value: clibase.BoolOf(&trial),
},
{
Flag: "use-token-for-session",
Description: "By default, the CLI will generate a new session token when logging in. This flag will instead use the provided token as the session token.",
Value: clibase.BoolOf(&useTokenForSession),
},
}
return cmd
}
Expand Down