Skip to content

Commit a4d7a4a

Browse files
committed
Reworded auth extension functions
Signed-off-by: Seb Julliand <[email protected]>
1 parent fe0ea8e commit a4d7a4a

File tree

3 files changed

+10
-10
lines changed

3 files changed

+10
-10
lines changed

src/api/Storage.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -205,9 +205,9 @@ export class ConnectionStorage extends Storage {
205205
await this.set(RECENTLY_OPENED_FILES_KEY, undefined);
206206
}
207207

208-
async addAuthorisedExtension(extension: vscode.Extension<any>) {
208+
async grantExtensionAuthorisation(extension: vscode.Extension<any>) {
209209
const extensions = this.getAuthorisedExtensions();
210-
if (!this.isExtensionAuthorised(extension)) {
210+
if (!this.getExtensionAuthorisation(extension)) {
211211
extensions.push({
212212
id: extension.id,
213213
displayName: extension.packageJSON.displayName,
@@ -218,23 +218,23 @@ export class ConnectionStorage extends Storage {
218218
}
219219
}
220220

221-
isExtensionAuthorised(extension: vscode.Extension<any>) {
221+
getExtensionAuthorisation(extension: vscode.Extension<any>) {
222222
const authorisedExtension = this.getAuthorisedExtensions().find(authorisedExtension => authorisedExtension.id === extension.id);
223223
if (authorisedExtension) {
224224
authorisedExtension.lastAccess = new Date().getTime();
225225
}
226-
return authorisedExtension !== undefined;
226+
return authorisedExtension;
227227
}
228228

229229
getAuthorisedExtensions(): AuthorisedExtension[] {
230230
return this.get<AuthorisedExtension[]>(AUTHORISED_EXTENSIONS_KEY) || [];
231231
}
232232

233-
removeAllAuthorisedExtension() {
234-
this.removeAuthorisedExtension(this.getAuthorisedExtensions());
233+
revokeAllExtensionAuthorisations() {
234+
this.revokeExtensionAuthorisation(...this.getAuthorisedExtensions());
235235
}
236236

237-
removeAuthorisedExtension(extensions: AuthorisedExtension[]) {
237+
revokeExtensionAuthorisation(...extensions: AuthorisedExtension[]) {
238238
const newExtensions = this.getAuthorisedExtensions().filter(ext => !extensions.includes(ext));
239239
return this.set(AUTHORISED_EXTENSIONS_KEY, newExtensions);
240240
}

src/instantiate.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -642,7 +642,7 @@ export async function loadAllofExtension(context: vscode.ExtensionContext) {
642642
const storedPassword = await context.secrets.get(connectionKey);
643643

644644
if (storedPassword) {
645-
let isAuthed = storage.isExtensionAuthorised(extension);
645+
let isAuthed = storage.getExtensionAuthorisation(extension) !== undefined;
646646

647647
if (!isAuthed) {
648648
const detail = `The ${displayName} extension is requesting access to your password for this connection. ${reason ? `\n\nReason: ${reason}` : `The extension did not provide a reason for password access.`}`;
@@ -669,7 +669,7 @@ export async function loadAllofExtension(context: vscode.ExtensionContext) {
669669

670670
switch (result) {
671671
case `Allow`:
672-
await storage.addAuthorisedExtension(extension);
672+
await storage.grantExtensionAuthorisation(extension);
673673
isAuthed = true;
674674
done = true;
675675
break;

src/webviews/settings/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ export class SettingsUI {
238238
break;
239239

240240
case `clearAllowedExts`:
241-
instance.getStorage()?.removeAllAuthorisedExtension();
241+
instance.getStorage()?.revokeAllExtensionAuthorisations();
242242
break;
243243

244244
default:

0 commit comments

Comments
 (0)