提交 1a1ab8a4 编写于 作者: R Rachel Macfarlane

Better handling for MS auth provider when refresh token is not requested

上级 b3fb87f5
...@@ -87,6 +87,10 @@ export class AzureActiveDirectoryService { ...@@ -87,6 +87,10 @@ export class AzureActiveDirectoryService {
try { try {
const sessions = this.parseStoredData(storedData); const sessions = this.parseStoredData(storedData);
const refreshes = sessions.map(async session => { const refreshes = sessions.map(async session => {
if (!session.refreshToken) {
return Promise.resolve();
}
try { try {
await this.refreshToken(session.refreshToken, session.scope, session.id); await this.refreshToken(session.refreshToken, session.scope, session.id);
} catch (e) { } catch (e) {
...@@ -148,7 +152,7 @@ export class AzureActiveDirectoryService { ...@@ -148,7 +152,7 @@ export class AzureActiveDirectoryService {
const sessions = this.parseStoredData(storedData); const sessions = this.parseStoredData(storedData);
let promises = sessions.map(async session => { let promises = sessions.map(async session => {
const matchesExisting = this._tokens.some(token => token.scope === session.scope && token.sessionId === session.id); const matchesExisting = this._tokens.some(token => token.scope === session.scope && token.sessionId === session.id);
if (!matchesExisting) { if (!matchesExisting && session.refreshToken) {
try { try {
await this.refreshToken(session.refreshToken, session.scope, session.id); await this.refreshToken(session.refreshToken, session.scope, session.id);
addedIds.push(session.id); addedIds.push(session.id);
...@@ -242,6 +246,10 @@ export class AzureActiveDirectoryService { ...@@ -242,6 +246,10 @@ export class AzureActiveDirectoryService {
public async login(scope: string): Promise<vscode.AuthenticationSession2> { public async login(scope: string): Promise<vscode.AuthenticationSession2> {
Logger.info('Logging in...'); Logger.info('Logging in...');
if (!scope.includes('offline_access')) {
Logger.info('Warning: The \'offline_access\' scope was not included, so the generated token will not be able to be refreshed.');
}
return new Promise(async (resolve, reject) => { return new Promise(async (resolve, reject) => {
if (vscode.env.uiKind === vscode.UIKind.Web) { if (vscode.env.uiKind === vscode.UIKind.Web) {
resolve(this.loginWithoutLocalServer(scope)); resolve(this.loginWithoutLocalServer(scope));
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册