Prevent misuse of RequestAccess

This commit is contained in:
boatbomber 2023-07-04 19:21:32 -07:00
parent 91cba1b0e9
commit dcfdf7fabd
2 changed files with 29 additions and 6 deletions

View file

@ -314,9 +314,16 @@ function App:releaseSyncLock()
Log.trace("Could not release sync lock because it is owned by {}", lock.Value)
end
function App:requestPermission(source: string, name: string, apis: {string}, initialState: {[string]: boolean?}): {[string]: boolean}
function App:requestPermission(plugin: Plugin, source: string, name: string, apis: {string}, initialState: {[string]: boolean?}): {[string]: boolean}
local responseEvent = Instance.new("BindableEvent")
Log.info("The third-party plugin '{}' is requesting permission to use the API!", name)
local unloadProtection = plugin.Unloading:Connect(function()
Log.warn("Cancelling API permission request for '{}' because the third-party plugin has been removed.", name)
responseEvent:Fire(initialState)
end)
self:setState(function(state)
state.popups[source .. " Permissions"] = {
name = name,
@ -338,6 +345,7 @@ function App:requestPermission(source: string, name: string, apis: {string}, ini
local response = responseEvent.Event:Wait()
responseEvent:Destroy()
unloadProtection:Disconnect()
self:setState(function(state)
state.popups[source .. " Permissions"] = nil