Skip to content

Commit

Permalink
Fix StorageWrapper instantiation
Browse files Browse the repository at this point in the history
  • Loading branch information
sirdiego committed May 18, 2020
1 parent 517fb3a commit 7e70bdb
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 6 deletions.
4 changes: 3 additions & 1 deletion CognitoAuthScheme.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export default class CognitoAuthScheme {
this.name = options._name;
this.options = Object.assign({}, DEFAULTS, options);

this.$storage = new UniversalStorageWrapper(this.$auth.$storage);
this.$storage = new UniversalStorageWrapper(this.$auth.$storage, this.options.clientId);
this.$pool = new CognitoUserPool({
UserPoolId: this.options.userPoolId,
ClientId: this.options.clientId,
Expand Down Expand Up @@ -85,6 +85,8 @@ export default class CognitoAuthScheme {
if (this.options.autoFetchUser) {
await this.fetchUser();
}

return result;
}

async setUserToken(tokenValue) {
Expand Down
6 changes: 3 additions & 3 deletions UniversalStorageWrapper.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
export class UniversalStorageWrapper /* implements ICognitoStorage */ {
constructor(storage, poolId) {
constructor(storage, clientId) {
this.storage = storage;
this.poolId = poolId;
this.clientId = clientId;
}

setItem(key /* : string */, value /* : string */) /* : void */ {
Expand All @@ -14,7 +14,7 @@ export class UniversalStorageWrapper /* implements ICognitoStorage */ {
this.storage.removeUniversal(key);
}
clear() /* : void */ {
let prefix = `auth.CognitoIdentityServiceProvider.${this.poolId}.`;
let prefix = `auth.CognitoIdentityServiceProvider.${this.clientId}.`;
const lastAuthUser = this.getItem(prefix + "LastAuthUser");
if (!lastAuthUser) {
return;
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@sirdiego/nuxt-auth-cognito-scheme",
"version": "1.0.3",
"version": "1.0.4",
"description": "Use amazon-cognito-identity-js with the Nuxt.js Auth Module.",
"main": "index.js",
"author": "diego <[email protected]>",
Expand Down

0 comments on commit 7e70bdb

Please sign in to comment.