Skip to content

Commit

Permalink
fix/accounts: Do not prefill the dotcom URL in the Enterprise login f…
Browse files Browse the repository at this point in the history
…ield (#6418)

When you last logged into dot com, we pre-fill the enterprise login URL
with https://sourcegraph.com. This is contrary to our efforts to get
Enterprise users to log into the right endpoint.

You can still log in to dot com using the handy enterprise login
method/hack. We just won't prefill that URL.

Fixes CODY-4534.

## Test plan

1. Sign out of all your accounts.
2. Sign in to dotcom. This works with social login buttons or signing
into https://sourcegraph.com as an "Enterprise" URL.
3. Go to https://sourcegraph.com/user/settings/tokens and delete the
token you are using.
4. Reload VSCode, or wait for it to log you out.
5. Go to sign in to an enterprise account. Verify that the URL field has
a placeholder like https://instance. and NOT https://sourcegraph.com
6. Sign in to s2.
7. Go to https://sourcegraph.sourcegraph.com/user/settings/tokens and
delete the token you are using.
8. Reload VSCode, or wait for it to log you out.
9. Go to sign in to an enterprise account. Verify that the URL field is
prefilled with https://sourcegraph.sourcegraph.com
10. Run a new instance of VSCode with `--user-data-dir=/tmp/foo
--profile-temp` to simulate a fresh install.
11. Go to sign in to an enterprise account. Verify that the URL field
has a placeholder like https://instance. and NOT https://sourcegraph.com

Note, if you sign out (cmd-shift-p Cody: Sign Out) etc. then the field
is *not* prefilled, we delete the record of that account. It is new
installs, or when accounts are left over from expired tokens, that you
get the prefilling.

Note: This is not easily e2e testable because Cody Web has fixed the
dotcom override URL in the vite config, which is a compile-time static.
To make this testable we would need to configure the dotcom override URL
as the webview boots up. This is a big job because DOTCOM_URL is a
module-level constant, etc.
  • Loading branch information
dominiccooney authored Jan 16, 2025
1 parent 573885c commit 684ef16
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions vscode/webviews/AuthPage.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
import type { AuthStatus, CodyIDE, TelemetryRecorder } from '@sourcegraph/cody-shared'
import {
type AuthStatus,
type CodyIDE,
type TelemetryRecorder,
isDotCom,
} from '@sourcegraph/cody-shared'

import signInLogoSourcegraph from '../resources/sourcegraph-mark.svg'
import { type AuthMethod, isSourcegraphToken } from '../src/chat/protocol'
Expand Down Expand Up @@ -286,7 +291,7 @@ const ClientSignInForm: React.FC<ClientSignInFormProps> = memo(
isSubmitting: false,
showAuthError: false,
formData: {
endpoint: authStatus?.endpoint ?? '',
endpoint: authStatus && !isDotCom(authStatus) ? authStatus.endpoint : '',
accessToken: '',
},
})
Expand Down

0 comments on commit 684ef16

Please sign in to comment.