Skip to content

Commit

Permalink
Rollback priv check
Browse files Browse the repository at this point in the history
  • Loading branch information
rajyraman committed Feb 4, 2021
1 parent 52568db commit f684c12
Show file tree
Hide file tree
Showing 6 changed files with 5 additions and 82 deletions.
2 changes: 1 addition & 1 deletion app/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,6 @@
"/scripts/Sdk.Soap.min.js",
"/scripts/levelup.extension.js"
],
"version": "3.5.6",
"version": "3.5.7",
"manifest_version": 2
}
21 changes: 0 additions & 21 deletions app/scripts/background.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,6 @@ chrome.runtime.onMessage.addListener(function (message: IExtensionMessage, sende
if (message.type === 'Page') {
let c = message.category.toString();
switch (c) {
case 'canImpersonate':
chrome.tabs.query({ active: true }, function (tabs) {
chrome.tabs.sendMessage(tabs[0].id, {
category: 'canImpersonate',
type: 'Background',
content: message.content,
});
});
break;
case 'allUsers':
chrome.tabs.query({ active: true }, function (tabs) {
chrome.tabs.sendMessage(tabs[0].id, {
Expand Down Expand Up @@ -121,18 +112,6 @@ chrome.runtime.onMessage.addListener(function (message: IExtensionMessage, sende
}
);
break;
case 'canImpersonate':
chrome.tabs.query(
{
active: true,
},
function (tabs) {
chrome.tabs.executeScript(tabs[0].id, {
code: `window.postMessage({ type: '${c}', category: '${message.type}' }, '*');`,
});
}
);
break;
}
} else {
chrome.tabs.query(
Expand Down
36 changes: 0 additions & 36 deletions app/scripts/inject/levelup.servicecalls.ts
Original file line number Diff line number Diff line change
Expand Up @@ -169,42 +169,6 @@ export class Service {
});
}

canImpersonate() {
const userId = this.utility.Xrm?.Utility?.getGlobalContext()?.getUserId() ?? this.utility.Xrm.Page.context.getUserId();
this.utility
.fetch(
'systemusers',
null,
null,
null,
`<fetch top="1" >
<entity name="systemuser" >
<filter>
<condition attribute="systemuserid" operator="eq" value="${userId}" />
</filter>
<link-entity name="systemuserroles" from="systemuserid" to="systemuserid" intersect="true" >
<link-entity name="role" from="roleid" to="roleid" intersect="true" >
<link-entity name="roleprivileges" from="roleid" to="roleid" intersect="true" >
<link-entity name="privilege" from="privilegeid" to="privilegeid" intersect="true" >
<filter>
<condition attribute="name" operator="eq" value="prvActOnBehalfOfAnotherUser " />
</filter>
</link-entity>
</link-entity>
</link-entity>
</link-entity>
</entity>
</fetch>`
)
.then((entities) => {
let canImpersonate = entities.length > 0;
this.utility.messageExtension(canImpersonate, 'canImpersonate');
})
.catch((err) => {
console.log(err);
});
}

entityMetadata() {
this.utility
.fetch(`EntityDefinitions`, 'LogicalName,ObjectTypeCode,LogicalCollectionName,ChangeTrackingEnabled,DisplayName')
Expand Down
5 changes: 1 addition & 4 deletions app/scripts/interfaces/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,7 @@ export type Category =
| 'optionsets'
| 'environment'
| 'activation'
| 'changeUser'
| 'canImpersonate';
| 'changeUser';

export type ExtensionState = 'On' | 'Off';

Expand Down Expand Up @@ -129,7 +128,6 @@ export enum LocalStorage {
isImpersonating = 'isImpersonating',
userId = 'userId',
userName = 'userName',
canImpersonate = 'canImpersonate'
}

export interface IExtensionLocalStorage {
Expand All @@ -139,5 +137,4 @@ export interface IExtensionLocalStorage {
isImpersonating: boolean;
userId: string;
userName: string;
canImpersonate: boolean;
}
21 changes: 2 additions & 19 deletions app/scripts/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,6 @@ import { IExtensionMessage, LocalStorage, IExtensionLocalStorage } from './inter
chrome.runtime.onMessage.addListener((message: IExtensionMessage, sender, response) => {
if (message.type === 'Page') {
switch (message.category) {
case 'canImpersonate':
var canImpersonate = message.content;
document.getElementById('impersonate-tab').style.display = !canImpersonate ? 'none' : 'block';

chrome.storage.local.set({
[LocalStorage.canImpersonate]: canImpersonate,
});
break;
case 'allUsers':
chrome.storage.local.set({
[LocalStorage.usersList]: message.content,
Expand Down Expand Up @@ -120,18 +112,9 @@ window.addEventListener('DOMContentLoaded', function () {
});

function initImpersonateTab() {
chrome.storage.local.get([LocalStorage.usersList,LocalStorage.canImpersonate], function (result: IExtensionLocalStorage) {
chrome.storage.local.get([LocalStorage.usersList], function (result: IExtensionLocalStorage) {
let users = result.usersList;
let canImpersonate = result.canImpersonate;

if(canImpersonate == undefined){
chrome.runtime.sendMessage({
category: 'canImpersonate',
type: 'API',
});
}else{
document.getElementById('impersonate-tab').style.display = !canImpersonate ? 'none' : 'block';
}
document.getElementById('impersonate-tab').style.display = 'block';

if (!users) {
chrome.runtime.sendMessage({
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "levelup-for-dynamics-365-power-apps",
"private": true,
"version": "3.5.6",
"version": "3.5.7",
"description": "Quickly perform advanced/hidden actions in Dynamics 365/Power Apps, without bookmarklets.",
"scripts": {
"start": "npm run dev:chrome",
Expand Down

0 comments on commit f684c12

Please sign in to comment.