mirror of
https://github.com/keycloak/keycloak.git
synced 2026-05-08 08:01:18 -05:00
Closes #23872 Signed-off-by: Jon Koops <jonkoops@gmail.com>
This commit is contained in:
+19
-1
@@ -20,12 +20,30 @@
|
||||
}
|
||||
}
|
||||
|
||||
// See https://developer.mozilla.org/en-US/docs/Web/API/Storage_Access_API/Using#checking_and_requesting_storage_access
|
||||
async function hasStorageAccess() {
|
||||
// Check if the Storage Access API is supported, if not, pretend we have access.
|
||||
// This is for older browsers, where support can be determined using the test cookie.
|
||||
if (!("hasStorageAccess" in document)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return document.hasStorageAccess();
|
||||
// Check if we already have been granted storage access, if so, signal access.
|
||||
if (await document.hasStorageAccess()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
try {
|
||||
// Attempt to request storage access without a user interaction.
|
||||
// This might fail, and if it does an exception will be thrown.
|
||||
await document.requestStorageAccess();
|
||||
|
||||
// If no exceptions are thrown, then signal access.
|
||||
return true;
|
||||
} catch (error) {
|
||||
// If an exception is thrown, then signal no access.
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
function attemptWithTestCookie() {
|
||||
|
||||
+19
-1
@@ -72,12 +72,30 @@
|
||||
return "error";
|
||||
}
|
||||
|
||||
// See https://developer.mozilla.org/en-US/docs/Web/API/Storage_Access_API/Using#checking_and_requesting_storage_access
|
||||
async function hasStorageAccess() {
|
||||
// Check if the Storage Access API is supported, if not, pretend we have access.
|
||||
// This is for older browsers, where support can be determined using the test cookie.
|
||||
if (!("hasStorageAccess" in document)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return document.hasStorageAccess();
|
||||
// Check if we already have been granted storage access, if so, signal access.
|
||||
if (await document.hasStorageAccess()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
try {
|
||||
// Attempt to request storage access without a user interaction.
|
||||
// This might fail, and if it does an exception will be thrown.
|
||||
await document.requestStorageAccess();
|
||||
|
||||
// If no exceptions are thrown, then signal access.
|
||||
return true;
|
||||
} catch (error) {
|
||||
// If an exception is thrown, then signal no access.
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
function getSessionCookie() {
|
||||
|
||||
Reference in New Issue
Block a user