File tree Expand file tree Collapse file tree 1 file changed +18
-4
lines changed Expand file tree Collapse file tree 1 file changed +18
-4
lines changed Original file line number Diff line number Diff line change @@ -162,10 +162,7 @@ export class OAuthService extends AuthConfig implements OnDestroy {
162
162
}
163
163
164
164
// in IE, sessionStorage does not always survive a redirect
165
- if (
166
- typeof window !== 'undefined' &&
167
- typeof window [ 'localStorage' ] !== 'undefined'
168
- ) {
165
+ if ( this . checkLocalStorageAccessable ( ) ) {
169
166
const ua = window ?. navigator ?. userAgent ;
170
167
const msie = ua ?. includes ( 'MSIE ' ) || ua ?. includes ( 'Trident' ) ;
171
168
@@ -177,6 +174,23 @@ export class OAuthService extends AuthConfig implements OnDestroy {
177
174
this . setupRefreshTimer ( ) ;
178
175
}
179
176
177
+ private checkLocalStorageAccessable ( ) {
178
+ if ( typeof window === 'undefined' )
179
+ return false ;
180
+
181
+ const test = 'test' ;
182
+ try {
183
+ if ( typeof window [ 'localStorage' ] === 'undefined' )
184
+ return false ;
185
+
186
+ localStorage . setItem ( test , test ) ;
187
+ localStorage . removeItem ( test ) ;
188
+ return true ;
189
+ } catch ( e ) {
190
+ return false ;
191
+ }
192
+ }
193
+
180
194
/**
181
195
* Use this method to configure the service
182
196
* @param config the configuration
You can’t perform that action at this time.
0 commit comments