Skip to content

Commit

Permalink
update storage key for auth
Browse files Browse the repository at this point in the history
  • Loading branch information
codediodeio committed Mar 11, 2020
1 parent 54ce044 commit 3f82db8
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "0.1.2",
"version": "0.1.3",
"name": "sveltefire",
"svelte": "src/index.js",
"main": "dist/index.js",
Expand Down
6 changes: 3 additions & 3 deletions src/auth.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,19 @@ import { assertApp } from './helpers';
export function userStore(opts = { persist: null }) {

const auth = assertApp('auth');
const k = 'sveltefire_user';
const storageKey = 'sveltefire_user';
let cached = null;

const { persist } = opts;

if (persist) {
cached = JSON.parse(opts.persist.getItem(k));
cached = JSON.parse(opts.persist.getItem(storageKey));
}

const store = writable(cached, () => {
const teardown = auth.onAuthStateChanged(u => {
set(u);
persist && opts.persist.setItem(k, JSON.stringify(u));
persist && opts.persist.setItem(storageKey, JSON.stringify(u));
});
return () => teardown;
});
Expand Down

0 comments on commit 3f82db8

Please sign in to comment.