Skip to content
This repository has been archived by the owner on Nov 6, 2020. It is now read-only.

Commit

Permalink
Add signin/signout, version to 1.113.0 (#91)
Browse files Browse the repository at this point in the history
* Add signin/signout, version to 1.113.0

* Fix up some wording
  • Loading branch information
Jeff Young committed Feb 7, 2017
1 parent e16f9d3 commit 53f175f
Show file tree
Hide file tree
Showing 8 changed files with 61 additions and 31 deletions.
46 changes: 32 additions & 14 deletions README.md
Expand Up @@ -27,9 +27,9 @@ have a Team Services account (or a Team Foundation Server instance), you may cre
the extension will detect the change to the remote and attempt to contact the Team Services account (or Team Foundation Server).

## Installation
First, you will need to install [Visual Studio Code](https://code.visualstudio.com/download) `1.0.0` or later.
First, you will need to install [Visual Studio Code](https://code.visualstudio.com/download) `1.7.0` or later.

To install the extension with the latest version of Visual Studio Code (version 1.3.1 is the latest as of this writing), bring up the Visual Studio Code Command Palette (`F1`),
To install the extension with the latest version of Visual Studio Code (version 1.9.0 is the latest as of this writing), bring up the Visual Studio Code Command Palette (`F1`),
type `install` and choose `Extensions: Install Extensions`. In the `Search Extensions in Marketplace` text box, type `team`. Find
the `Visual Studio Team Services` extension published by *Microsoft* and click the `Install` button. Restart Visual Studio Code.

Expand All @@ -53,21 +53,21 @@ Details on how to connect to either Team Services or Team Foundation Server are
Once you have installed the extension, open either the root folder or a sub-folder of the cloned Git repository. Once a Team
Services or Team Foundation Server 2015 Update 2 (or later) repository is detected by the extension, you will need to provide
your credentials (if credentials weren't already found). If you are required to provide your credentials, there will be an
indicator in the status bar whose message will indicate that you need to login in.
indicator in the status bar whose message will indicate that you need to sign in.

The indicator looks like this:

![Team Error indicator](assets/team-error.png)

To log in to your account, run the `team login` command. If your repository is a Team Services repository,
To sign in to your account, run the `team signin` command. If your repository is a Team Services repository,
you will be prompted to enter your personal access token. When you do, it will be stored securely on your
computer and used to connect to Team Services. If your repository is on Team Foundation Server 2015 Update
2 or later, you will be prompted to enter your username and password. After both are provided, they will
be stored securely on your computer and used to connect to your TFS server.

Once your credentials are verified, the status bar indicators will be active and the remaining commands will
be ready to use. The stored credentials will be used for each connection to the server until they are either
removed by the `team logout` command or overwritten by a subsequent `team login` command.
removed by the `team signout` command or overwritten by a subsequent `team signin` command.

**Note:** In order for the extension to be activated, a repository *folder* must be opened. The extension
won't be activated if only a single *file* in the repository is opened.
Expand Down Expand Up @@ -118,6 +118,15 @@ feedback of up to 1000 characters. Optionally, provide your email address so we
you do not want to provide your email address, just leave it empty (we'll still get your feedback). *Note:*
Feedback can be sent even if telemetry reporting is disabled.

* `team signin` – Use this command to sign in to a Team Services account or Team Foundation Server 2015 Update 2
(and later) server. When your credentials are provided, they will be stored securely on your computer. The saved
credentials will be used for that account until they are removed by the `team signout` command or overwritten by a
subsequent `team signin` command. See the "Secure Credential Storage" topic below for more details.

* `team signout` – Use this command to sign out from a Team Services account or Team Foundation Server 2015 Update 2
(and later) server. Signing out will remove your credentials from your local computer. To sign back in, you will
need to run the `team signin` command again.

* `team view blame` – If a file in the repository is opened in the editor, it will open your browser to the
blame page for that file in the current branch in the server repository.

Expand All @@ -127,14 +136,9 @@ blame page for that file in the current branch in the server repository.
history page for that file in the current branch in the server repository. Otherwise, the history of the current
branch in the server repository will be opened.

* `team login` – Use this command to log in to a Team Services account or Team Foundation Server 2015 Update 2
(and later) server. When your credentials are provided, they will be stored securely on your computer. The saved
credentials will be used for that account until they are removed by the `team logout` command or overwritten by a
subsequent `team login` command. See the "Secure Credential Storage" topic below for more details.
* `team login` – With version 1.113.0, this command is being deprecated in favor of `team signin`. It will be removed in a future update.

* `team logout` – Use this command to log out from a Team Services account or Team Foundation Server 2015 Update 2
(and later) server. Logging out will remove your credentials from your local computer. To log back in, you will
need to run the `team login` command again.
* `team logout` – With version 1.113.0, this command is being deprecated in favor of `team signout`. It will be removed in a future update.

* `team view pull requests` – Same behavior as clicking on the Pull Requests status bar item.

Expand All @@ -150,10 +154,10 @@ work item in your browser. This command will return a maximum of 200 results
work items...". Choosing that option will open your browser to show all of the results of your query.

## Secure Credential Storage
When you run the `team login` command, the credentials that you provide will be stored securely on your computer. On
When you run the `team signin` command, the credentials that you provide will be stored securely on your computer. On
Windows, your credentials wil be stored by Windows Credential Manager. On OS X, your credentials will be stored in the
Keychain. On Linux, your credentials will be stored in a file on your local file system in a subdirectory of your
home folder. That file is created only with RW rights for the user running Visual Studio Code. It is not encrypted
home folder. That file is created only with RW rights for the user running Visual Studio Code. It is **not encrypted**
on disk.

## How to disable telemetry reporting
Expand Down Expand Up @@ -211,6 +215,20 @@ then the account name to use is `servername:8080`.
You can also create a *global* pinned query which will be the default if you have not configured one for your account by
replacing *your-account-name* with *global* in the previous examples.

## Using External (non-Microsoft) Source Repositories
With version 1.113.0, you can now use the extension with repositories that are *not* hosted with either Team Services or Team Foundation Server. You
will be able to monitor your builds (for a specific build definition) and work items that *are* hosted with either Team Services or Team Foundation
Server by specifying your account information. To do this, set the following settings in VS Code. It is recommended that you set these in your
Workspace Settings (and not User Settings). You will, of course, still need to authenticate (provide credentials).

```javascript
"team.remoteUrl": "https://account.visualstudio.com",
"team.teamProject": "myTeamProject",
"team.buildDefinitionId": 42,
```

To determine your build definition id, open the build summary for the build you'd like to monitor and grab the value of the _buildId=_ parameter in the url.

## Support
Support for this extension is provided on our [GitHub Issue Tracker](https://github.com/Microsoft/vsts-vscode/issues). You
can submit a [bug report](https://github.com/Microsoft/vsts-vscode/issues/new), a [feature request](https://github.com/Microsoft/vsts-vscode/issues/new)
Expand Down
10 changes: 9 additions & 1 deletion package.json
Expand Up @@ -2,7 +2,7 @@
"name": "team",
"displayName": "Visual Studio Team Services",
"description": "Connect to Team Services, monitor your builds and manage your pull requests and work items for your source repositories",
"version": "1.108.0",
"version": "1.113.0",
"publisher": "ms-vsts",
"icon": "assets/team.png",
"markdown": "standard",
Expand Down Expand Up @@ -134,6 +134,14 @@
"command": "team.Logout",
"title": "team logout"
},
{
"command": "team.Signin",
"title": "team signin"
},
{
"command": "team.Signout",
"title": "team signout"
},
{
"command": "tfvc.Status",
"title": "TFVC: Status"
Expand Down
6 changes: 4 additions & 2 deletions src/extension.ts
Expand Up @@ -26,8 +26,10 @@ export function activate(context: ExtensionContext) {
_extensionManager = new ExtensionManager();

context.subscriptions.push(commands.registerCommand(CommandNames.GetPullRequests, () => _extensionManager.Team.GetMyPullRequests()));
context.subscriptions.push(commands.registerCommand(CommandNames.Login, () => _extensionManager.Team.Login()));
context.subscriptions.push(commands.registerCommand(CommandNames.Logout, () => _extensionManager.Team.Logout()));
context.subscriptions.push(commands.registerCommand(CommandNames.Login, () => _extensionManager.Team.Signin()));
context.subscriptions.push(commands.registerCommand(CommandNames.Logout, () => _extensionManager.Team.Signout()));
context.subscriptions.push(commands.registerCommand(CommandNames.Signin, () => _extensionManager.Team.Signin()));
context.subscriptions.push(commands.registerCommand(CommandNames.Signout, () => _extensionManager.Team.Signout()));
context.subscriptions.push(commands.registerCommand(CommandNames.OpenBlamePage, () => _extensionManager.Team.OpenBlamePage()));
context.subscriptions.push(commands.registerCommand(CommandNames.OpenBuildSummaryPage, () => _extensionManager.Team.OpenBuildSummaryPage()));
context.subscriptions.push(commands.registerCommand(CommandNames.OpenFileHistory, () => _extensionManager.Team.OpenFileHistory()));
Expand Down
8 changes: 4 additions & 4 deletions src/extensionmanager.ts
Expand Up @@ -156,17 +156,17 @@ export class ExtensionManager {
}

private displayNoCredentialsMessage(): void {
let error: string = Strings.NoTeamServerCredentialsRunLogin;
let displayError: string = Strings.NoTeamServerCredentialsRunLogin;
let error: string = Strings.NoTeamServerCredentialsRunSignin;
let displayError: string = Strings.NoTeamServerCredentialsRunSignin;
let messageItem: UrlMessageItem = undefined;
if (this._serverContext.RepoInfo.IsTeamServices === true) {
messageItem = { title : Strings.LearnMore,
url : Constants.TokenLearnMoreUrl,
telemetryId: TelemetryEvents.TokenLearnMoreClick };
//Need different messages for popup message and status bar
//Add the account name to the message to help the user
error = util.format(Strings.NoAccessTokenRunLogin, this._serverContext.RepoInfo.Account);
displayError = util.format(Strings.NoAccessTokenLearnMoreRunLogin, this._serverContext.RepoInfo.Account);
error = util.format(Strings.NoAccessTokenRunSignin, this._serverContext.RepoInfo.Account);
displayError = util.format(Strings.NoAccessTokenLearnMoreRunSignin, this._serverContext.RepoInfo.Account);
}
Logger.LogError(error);
this.setErrorStatus(error, CommandNames.Login, false);
Expand Down
2 changes: 2 additions & 0 deletions src/helpers/constants.ts
Expand Up @@ -29,6 +29,8 @@ export class CommandNames {
static RefreshPollingStatus: string = CommandNames.CommandPrefix + "RefreshPollingStatus";
static Reinitialize: string = CommandNames.CommandPrefix + "Reinitialize";
static SendFeedback: string = CommandNames.CommandPrefix + "SendFeedback";
static Signin: string = CommandNames.CommandPrefix + "Signin";
static Signout: string = CommandNames.CommandPrefix + "Signout";
static ViewWorkItemQueries: string = CommandNames.CommandPrefix + "ViewWorkItemQueries";
static ViewWorkItems: string = CommandNames.CommandPrefix + "ViewWorkItems";
static ViewPinnedQueryWorkItems: string = CommandNames.CommandPrefix + "ViewPinnedQueryWorkItems";
Expand Down
6 changes: 3 additions & 3 deletions src/helpers/strings.ts
Expand Up @@ -14,9 +14,9 @@ export class Strings {
static NavigateToBuildSummary: string = "Click to view build";
static NavigateToTeamServicesWebSite: string = "Click to view your team project website.";
static NoAccessTokenFound: string = "A personal access token for this Team Services repository was not found in your local user settings.";
static NoAccessTokenLearnMoreRunLogin: string = "You are not connected to Team Services (%s). Select 'Learn more...' and then run the 'team login' command.";
static NoAccessTokenRunLogin: string = "You are not connected to Team Services (%s). Please run the 'team login' command.";
static NoTeamServerCredentialsRunLogin: string = "You are not connected to a Team Foundation Server. Please run the 'team login' command.";
static NoAccessTokenLearnMoreRunSignin: string = "You are not connected to Team Services (%s). Select 'Learn more...' and then run the 'team signin' command.";
static NoAccessTokenRunSignin: string = "You are not connected to Team Services (%s). Please run the 'team signin' command.";
static NoTeamServerCredentialsRunSignin: string = "You are not connected to a Team Foundation Server. Please run the 'team signin' command.";
static NoBuildsFound: string = "No builds were found for this repository and branch. Click to view your team project's build definitions page.";
static NoTfvcBuildsFound: string = "No builds were found for this repository. Click to view your team project's build definitions page.";
static NoRepoInformation: string = "No Team Services or Team Foundation Server repository configuration was found. Ensure you've opened a folder that contains a repository.";
Expand Down
2 changes: 1 addition & 1 deletion src/services/telemetry.ts
Expand Up @@ -16,7 +16,7 @@ export class TelemetryService {
private _appInsightsClient: Client;
private _serverContext: TeamServerContext;
private _telemetryEnabled: boolean = true;
private _extensionVersion: string = "1.108.0";
private _extensionVersion: string = "1.113.0";
private _collectionId: string = "UNKNOWN";
//Default to a new uuid in case the extension fails before being initialized
private _userId: string = uuid.v1();
Expand Down
12 changes: 6 additions & 6 deletions src/team-extension.ts
Expand Up @@ -57,16 +57,16 @@ export class TeamExtension {
}
}

public async Login() {
// For Login, we just need to verify _serverContext and don't want to set this._errorMessage
public async Signin() {
// For Signin, we just need to verify _serverContext and don't want to set this._errorMessage
if (this._manager.ServerContext !== undefined && this._manager.ServerContext.RepoInfo !== undefined && this._manager.ServerContext.RepoInfo.IsTeamFoundation === true) {
if (this._manager.ServerContext.RepoInfo.IsTeamFoundationServer === true) {
let defaultUsername : string = this.getDefaultUsername();
let username: string = await window.showInputBox({ value: defaultUsername || "", prompt: Strings.ProvideUsername + " (" + this._manager.ServerContext.RepoInfo.Account + ")", placeHolder: "", password: false });
if (username !== undefined && username.length > 0) {
let password: string = await window.showInputBox({ value: "", prompt: Strings.ProvidePassword + " (" + username + ")", placeHolder: "", password: true });
if (password !== undefined) {
Logger.LogInfo("Login: Username and Password provided as authentication.");
Logger.LogInfo("Signin: Username and Password provided as authentication.");
this._manager.CredentialManager.StoreCredentials(this._manager.ServerContext.RepoInfo.Host, username, password).then(() => {
// We don't test the credentials to make sure they're good here. Do so on the next command that's run.
this._manager.Reinitialize();
Expand All @@ -81,7 +81,7 @@ export class TeamExtension {
// Until Device Flow, we can prompt for the PAT for Team Services
let token: string = await window.showInputBox({ value: "", prompt: Strings.ProvideAccessToken + " (" + this._manager.ServerContext.RepoInfo.Account + ")", placeHolder: "", password: true });
if (token !== undefined) {
Logger.LogInfo("Login: Personal Access Token provided as authentication.");
Logger.LogInfo("Signin: Personal Access Token provided as authentication.");
this._manager.CredentialManager.StoreCredentials(this._manager.ServerContext.RepoInfo.Host, Constants.OAuth, token).then(() => {
this._manager.Reinitialize();
}).catch((reason) => {
Expand All @@ -104,11 +104,11 @@ export class TeamExtension {
}
}

public Logout() {
public Signout() {
// For Logout, we just need to verify _serverContext and don't want to set this._errorMessage
if (this._manager.ServerContext !== undefined && this._manager.ServerContext.RepoInfo !== undefined && this._manager.ServerContext.RepoInfo.IsTeamFoundation === true) {
this._manager.CredentialManager.RemoveCredentials(this._manager.ServerContext.RepoInfo.Host).then(() => {
Logger.LogInfo("Logout: Removed credentials for host '" + this._manager.ServerContext.RepoInfo.Host + "'");
Logger.LogInfo("Signout: Removed credentials for host '" + this._manager.ServerContext.RepoInfo.Host + "'");
this._manager.Reinitialize();
}).catch((reason) => {
let msg: string = Strings.UnableToRemoveCredentials + this._manager.ServerContext.RepoInfo.Host;
Expand Down

0 comments on commit 53f175f

Please sign in to comment.