@stevederico/skateboard-ui 2.14.0 → 2.15.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +5 -0
- package/core/Utilities.js +21 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
package/core/Utilities.js
CHANGED
|
@@ -723,11 +723,31 @@ export async function apiRequest(endpoint, options = {}) {
|
|
|
723
723
|
if (timeoutId) clearTimeout(timeoutId);
|
|
724
724
|
}
|
|
725
725
|
|
|
726
|
-
// Handle 401 (redirect to signout,
|
|
726
|
+
// Handle 401 (redirect to signout, or show auth overlay and retry)
|
|
727
727
|
if (response.status === 401) {
|
|
728
728
|
if (getConstants().authOverlay !== true) {
|
|
729
729
|
window.location.href = '/signout';
|
|
730
|
+
throw new Error('Unauthorized');
|
|
730
731
|
}
|
|
732
|
+
|
|
733
|
+
// In authOverlay mode: show sign-in overlay, retry request after auth
|
|
734
|
+
const dispatch = getDispatch();
|
|
735
|
+
if (dispatch) {
|
|
736
|
+
return new Promise((resolve, reject) => {
|
|
737
|
+
dispatch({
|
|
738
|
+
type: 'SHOW_AUTH_OVERLAY',
|
|
739
|
+
payload: async () => {
|
|
740
|
+
try {
|
|
741
|
+
const result = await apiRequest(endpoint, options);
|
|
742
|
+
resolve(result);
|
|
743
|
+
} catch (err) {
|
|
744
|
+
reject(err);
|
|
745
|
+
}
|
|
746
|
+
}
|
|
747
|
+
});
|
|
748
|
+
});
|
|
749
|
+
}
|
|
750
|
+
|
|
731
751
|
throw new Error('Unauthorized');
|
|
732
752
|
}
|
|
733
753
|
|