Skip to content
Merged
Changes from all commits
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
14 changes: 14 additions & 0 deletions internal/cli/auth/login.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ package auth

import (
"context"
"errors"
"fmt"
"os"
"time"
Expand Down Expand Up @@ -56,6 +57,11 @@ const (
LogoutToLoginAccountMsg = `run "atlas auth logout" first if you want to login with another Atlas account on the same Atlas CLI profile`
)

var (
ErrProjectIDNotFound = errors.New("you don't have access to this or it doesn't exist")
ErrOrgIDNotFound = errors.New("you don't have access to this organization ID or it doesn't exist")
)

type LoginOpts struct {
cli.DefaultSetterOpts
AccessToken string
Expand Down Expand Up @@ -189,6 +195,14 @@ func (opts *LoginOpts) setUpProfile(ctx context.Context) error {

// Only make references to profile if user was asked about org or projects
if opts.AskedOrgsOrProjects && opts.ProjectID != "" && opts.OrgID != "" {
if !opts.ProjectExists(config.ProjectID()) {
return ErrProjectIDNotFound
}

if !opts.OrgExists(config.OrgID()) {
return ErrOrgIDNotFound
}

_, _ = fmt.Fprint(opts.OutWriter, "\nYour profile is now configured.\n")
_, _ = fmt.Fprintf(opts.OutWriter, "You can use [%s config set] to change these settings at a later time.\n", config.BinName())
}
Expand Down