mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-17 02:51:36 -05:00
Merge from vscode 777931080477e28b7c27e8f7d4b0d69897945946 (#9220)
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
{
|
||||
"name": "vscode-account",
|
||||
"publisher": "vscode",
|
||||
"displayName": "Account",
|
||||
"description": "",
|
||||
"displayName": "%displayName%",
|
||||
"description": "%description%",
|
||||
"version": "0.0.1",
|
||||
"engines": {
|
||||
"vscode": "^1.42.0"
|
||||
@@ -15,6 +15,20 @@
|
||||
"*"
|
||||
],
|
||||
"main": "./out/extension.js",
|
||||
"contributes": {
|
||||
"commands": [
|
||||
{
|
||||
"command": "microsoft.signin",
|
||||
"title": "%signIn%",
|
||||
"category": "%displayName%"
|
||||
},
|
||||
{
|
||||
"command": "microsoft.signout",
|
||||
"title": "%signOut%",
|
||||
"category": "%displayName%"
|
||||
}
|
||||
]
|
||||
},
|
||||
"scripts": {
|
||||
"vscode:prepublish": "npm run compile",
|
||||
"compile": "gulp compile-extension:vscode-account",
|
||||
|
||||
6
extensions/vscode-account/package.nls.json
Normal file
6
extensions/vscode-account/package.nls.json
Normal file
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"displayName": "Microsoft Account",
|
||||
"description": "Microsoft authentication provider",
|
||||
"signIn": "Sign in",
|
||||
"signOut": "Sign out"
|
||||
}
|
||||
@@ -6,13 +6,15 @@
|
||||
import * as vscode from 'vscode';
|
||||
import { AzureActiveDirectoryService, onDidChangeSessions } from './AADHelper';
|
||||
|
||||
export async function activate(_: vscode.ExtensionContext) {
|
||||
export const DEFAULT_SCOPES = 'https://management.core.windows.net/.default offline_access';
|
||||
|
||||
export async function activate(context: vscode.ExtensionContext) {
|
||||
|
||||
const loginService = new AzureActiveDirectoryService();
|
||||
|
||||
await loginService.initialize();
|
||||
|
||||
vscode.authentication.registerAuthenticationProvider({
|
||||
context.subscriptions.push(vscode.authentication.registerAuthenticationProvider({
|
||||
id: 'MSA',
|
||||
displayName: 'Microsoft',
|
||||
onDidChangeSessions: onDidChangeSessions.event,
|
||||
@@ -28,7 +30,37 @@ export async function activate(_: vscode.ExtensionContext) {
|
||||
logout: async (id: string) => {
|
||||
return loginService.logout(id);
|
||||
}
|
||||
});
|
||||
}));
|
||||
|
||||
context.subscriptions.push(vscode.commands.registerCommand('microsoft.signin', () => {
|
||||
return loginService.login(DEFAULT_SCOPES);
|
||||
}));
|
||||
|
||||
context.subscriptions.push(vscode.commands.registerCommand('microsoft.signout', async () => {
|
||||
const sessions = loginService.sessions;
|
||||
if (sessions.length === 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (sessions.length === 1) {
|
||||
await loginService.logout(loginService.sessions[0].id);
|
||||
onDidChangeSessions.fire();
|
||||
return;
|
||||
}
|
||||
|
||||
const selectedSession = await vscode.window.showQuickPick(sessions.map(session => {
|
||||
return {
|
||||
id: session.id,
|
||||
label: session.accountName
|
||||
};
|
||||
}));
|
||||
|
||||
if (selectedSession) {
|
||||
await loginService.logout(selectedSession.id);
|
||||
onDidChangeSessions.fire();
|
||||
return;
|
||||
}
|
||||
}));
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user