Skip to content

Commit f14d458

Browse files
Fall back to not using localStorage if it's unavailable (#8)
* Fall back to not using localStorage if it's unavailable * Bump version
1 parent 2e0ecd6 commit f14d458

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"type": "git",
66
"url": "https://github.com/PropelAuth/javascript"
77
},
8-
"version": "2.0.0",
8+
"version": "2.0.1",
99
"keywords": [
1010
"auth",
1111
"user",

src/client.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -154,13 +154,17 @@ export function createClient(authOptions: IAuthOptions): IAuthClient {
154154
function updateLastLoggedOutAt() {
155155
const loggedOutAt = currentTimeSeconds()
156156
clientState.lastLoggedOutAtMessage = loggedOutAt
157-
localStorage.setItem(LOGGED_OUT_AT_KEY, String(loggedOutAt))
157+
if (hasLocalStorage()) {
158+
localStorage.setItem(LOGGED_OUT_AT_KEY, String(loggedOutAt))
159+
}
158160
}
159161

160162
function updateLastLoggedInAt() {
161163
const loggedInAt = currentTimeSeconds()
162164
clientState.lastLoggedInAtMessage = loggedInAt
163-
localStorage.setItem(LOGGED_IN_AT_KEY, String(loggedInAt))
165+
if (hasLocalStorage()) {
166+
localStorage.setItem(LOGGED_IN_AT_KEY, String(loggedInAt))
167+
}
164168
}
165169

166170
function setAuthenticationInfoAndUpdateDownstream(authenticationInfo: AuthenticationInfo | null) {

0 commit comments

Comments
 (0)