Skip to content

Commit

Permalink
[rel/stable] cherry pick 3025834 - Revert access token change - no si…
Browse files Browse the repository at this point in the history
…lent prompts (#350)

Cherry-pick of PR #346

Co-authored-by: davidjen@DAVIDJENDEV <[email protected]>
  • Loading branch information
davidjenni and davidjen@DAVIDJENDEV authored Nov 14, 2022
1 parent 6c5c374 commit fe636d5
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 15 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/PullRequest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@ jobs:
- name: Setup Node.js environment
uses: actions/setup-node@v2
with:
node-version: 14.x
node-version: 16.x

- name: Install dependencies
run: npm i -g npm
# - name: Install dependencies
# run: npm i -g npm

- name: Build and unit test
run: |
Expand Down
15 changes: 4 additions & 11 deletions src/web/client/common/fileSystemProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import { SaveEntityDetails } from './portalSchemaInterface';
import { fetchDataFromDataverseAndUpdateVFS } from './remoteFetchProvider';
import { saveData } from './remoteSaveProvider';
import * as nls from 'vscode-nls';
import { dataverseAuthentication } from './authenticationProvider';
const localize: nls.LocalizeFunc = nls.loadMessageBundle();

export class File implements vscode.FileStat {
Expand Down Expand Up @@ -262,14 +261,12 @@ export class PortalsFS implements vscode.FileSystemProvider {
private async _loadFromDataverseToVFS() {
const powerPlatformContext = await PowerPlatformExtensionContextManager.authenticateAndUpdateDataverseProperties();
await createFileSystem(this, powerPlatformContext.queryParamsMap.get(WEBSITE_NAME) as string);
const accessToken: string = await dataverseAuthentication(powerPlatformContext.queryParamsMap.get(ORG_URL) as string);

if (!accessToken) {
if (!powerPlatformContext.dataverseAccessToken) {
throw vscode.FileSystemError.NoPermissions();
}

await fetchDataFromDataverseAndUpdateVFS(
accessToken,
powerPlatformContext.dataverseAccessToken,
powerPlatformContext.entity,
powerPlatformContext.entityId,
powerPlatformContext.queryParamsMap,
Expand All @@ -285,11 +282,6 @@ export class PortalsFS implements vscode.FileSystemProvider {
const dataMap: Map<string, SaveEntityDetails> = powerPlatformContext.saveDataMap;

const dataverseOrgUrl = powerPlatformContext.queryParamsMap.get(ORG_URL) as string;
const accessToken: string = await dataverseAuthentication(dataverseOrgUrl);

if (!accessToken) {
throw vscode.FileSystemError.NoPermissions();
}

if (dataMap.get(uri.fsPath)?.getUseBase64Encoding as boolean) {
stringDecodedValue = toBase64(stringDecodedValue);
Expand All @@ -304,7 +296,8 @@ export class PortalsFS implements vscode.FileSystemProvider {
httpMethod.PATCH,
true);

await saveData(accessToken,
await saveData(
powerPlatformContext.dataverseAccessToken,
patchRequestUrl,
entityName,
uri,
Expand Down
5 changes: 4 additions & 1 deletion src/web/client/common/localStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export interface IPowerPlatformExtensionContext {
websiteLanguageIdToPortalLanguageMap: Map<string, string>;
websiteIdToLanguage: Map<string, string>;
entitiesFolderNameMap: Map<string, string> // FolderName for entity, schemaEntityName
dataverseAccessToken: string;
entityId: string;
entity: string;
rootDirectory: vscode.Uri;
Expand All @@ -40,6 +41,7 @@ class PowerPlatformExtensionContextManager {
entitiesFolderNameMap: this.entitiesFolderNameMap,
entity: '',
entityId: '',
dataverseAccessToken: '',
rootDirectory: vscode.Uri.parse(''),
saveDataMap: new Map<string, SaveEntityDetails>(),
defaultFileUri: vscode.Uri.parse(``)
Expand Down Expand Up @@ -70,7 +72,8 @@ class PowerPlatformExtensionContextManager {
... this.PowerPlatformExtensionContext,
websiteIdToLanguage: await this.websiteIdToLanguageMap(accessToken, dataverseOrgUrl),
websiteLanguageIdToPortalLanguageMap: await this.websiteLanguageIdToPortalLanguage(accessToken, dataverseOrgUrl),
languageIdCodeMap: await this.languageIdToCode(accessToken, dataverseOrgUrl)
languageIdCodeMap: await this.languageIdToCode(accessToken, dataverseOrgUrl),
dataverseAccessToken: accessToken,
};
}

Expand Down

0 comments on commit fe636d5

Please sign in to comment.