mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 18:46:40 -05:00
Merge from vscode e5834d3280fcd04898efeac32b9cf1b893f9b127 (#9385)
* Merge from vscode e5834d3280fcd04898efeac32b9cf1b893f9b127 * distro
This commit is contained in:
@@ -184,7 +184,7 @@ export class AzureActiveDirectoryService {
|
||||
private convertToSession(token: IToken): vscode.AuthenticationSession {
|
||||
return {
|
||||
id: token.sessionId,
|
||||
accessToken: () => this.resolveAccessToken(token),
|
||||
getAccessToken: () => this.resolveAccessToken(token),
|
||||
accountName: token.accountName,
|
||||
scopes: token.scope.split(' ')
|
||||
};
|
||||
@@ -192,7 +192,9 @@ export class AzureActiveDirectoryService {
|
||||
|
||||
private async resolveAccessToken(token: IToken): Promise<string> {
|
||||
if (token.accessToken && (!token.expiresAt || token.expiresAt > Date.now())) {
|
||||
Logger.info('Token available from cache');
|
||||
token.expiresAt
|
||||
? Logger.info(`Token available from cache, expires in ${token.expiresAt - Date.now()} milliseconds`)
|
||||
: Logger.info('Token available from cache');
|
||||
return Promise.resolve(token.accessToken);
|
||||
}
|
||||
|
||||
|
||||
@@ -5,6 +5,9 @@
|
||||
|
||||
import * as vscode from 'vscode';
|
||||
import { AzureActiveDirectoryService, onDidChangeSessions } from './AADHelper';
|
||||
import * as nls from 'vscode-nls';
|
||||
|
||||
const localize = nls.loadMessageBundle();
|
||||
|
||||
export const DEFAULT_SCOPES = 'https://management.core.windows.net/.default offline_access';
|
||||
|
||||
@@ -15,7 +18,7 @@ export async function activate(context: vscode.ExtensionContext) {
|
||||
await loginService.initialize();
|
||||
|
||||
context.subscriptions.push(vscode.authentication.registerAuthenticationProvider({
|
||||
id: 'MSA',
|
||||
id: 'microsoft',
|
||||
displayName: 'Microsoft',
|
||||
onDidChangeSessions: onDidChangeSessions.event,
|
||||
getSessions: () => Promise.resolve(loginService.sessions),
|
||||
@@ -45,6 +48,7 @@ export async function activate(context: vscode.ExtensionContext) {
|
||||
if (sessions.length === 1) {
|
||||
await loginService.logout(loginService.sessions[0].id);
|
||||
onDidChangeSessions.fire();
|
||||
vscode.window.showInformationMessage(localize('signedOut', "Successfully signed out."));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -58,6 +62,7 @@ export async function activate(context: vscode.ExtensionContext) {
|
||||
if (selectedSession) {
|
||||
await loginService.logout(selectedSession.id);
|
||||
onDidChangeSessions.fire();
|
||||
vscode.window.showInformationMessage(localize('signedOut', "Successfully signed out."));
|
||||
return;
|
||||
}
|
||||
}));
|
||||
|
||||
Reference in New Issue
Block a user