From a99a47038aa9f3a11ab073e9753715a2f21737f9 Mon Sep 17 00:00:00 2001 From: diego Date: Sun, 17 May 2020 16:31:03 +0200 Subject: [PATCH] Fix interval clear --- CognitoAuthScheme.js | 16 ++++++++-------- README.md | 18 ++++++++++++------ package-lock.json | 2 +- package.json | 2 +- 4 files changed, 22 insertions(+), 16 deletions(-) mode change 100644 => 100755 package-lock.json diff --git a/CognitoAuthScheme.js b/CognitoAuthScheme.js index 8c4a5dd..d0ce8cb 100644 --- a/CognitoAuthScheme.js +++ b/CognitoAuthScheme.js @@ -5,7 +5,7 @@ if (!process.client || !"fetch" in window) { import { AuthenticationDetails, CognitoUserPool, - CognitoUser + CognitoUser, } from "amazon-cognito-identity-js"; import { UniversalStorageWrapper } from "@sirdiego/nuxt-auth-cognito-scheme/UniversalStorageWrapper"; @@ -19,7 +19,7 @@ export default class CognitoAuthScheme { this.$pool = new CognitoUserPool({ UserPoolId: this.options.userPoolId, ClientId: this.options.clientId, - Storage: this.$storage + Storage: this.$storage, }); } @@ -149,7 +149,7 @@ export default class CognitoAuthScheme { if (process.client) { const interval = this.$auth.$storage.getState("interval"); if (interval) { - clearInterval(this.interval); + clearInterval(interval); this.$auth.$storage.removeState("interval"); } } @@ -164,17 +164,17 @@ export default class CognitoAuthScheme { return new Promise((resolve, reject) => { const authenticationDetails = new AuthenticationDetails({ Username, - Password + Password, }); const cognitoUser = new CognitoUser({ Username, Pool: this.$pool, - Storage: this.$storage + Storage: this.$storage, }); cognitoUser.authenticateUser(authenticationDetails, { - onSuccess: result => resolve(result), - onFailure: error => reject(error) + onSuccess: (result) => resolve(result), + onFailure: (error) => reject(error), }); }); } @@ -188,5 +188,5 @@ const DEFAULTS = { userPoolId: undefined, clientId: undefined, refreshInterval: 5 * 60 * 1000, - fetchUserCallback: false + fetchUserCallback: false, }; diff --git a/README.md b/README.md index b7053c5..0e6b6fd 100644 --- a/README.md +++ b/README.md @@ -20,16 +20,22 @@ Edit `nuxt.config.js`: { modules: [ '@nuxtjs/axios', - '@sirdiego/nuxt-auth-cognito-scheme', + '@sirdiego/nuxt-auth-cognito-scheme', // Insert before @nuxtjs/auth '@nuxtjs/auth' - ], - - auth: { + ], + auth: { strategies: { cognito: { + tokenType: "Bearer", + globalToken: true, + tokenName: "Authorization", + autoFetchUser: true, userPoolId: process.env.AWS_COGNITO_USER_POOL_ID, - clientId: process.env.AWS_COGNITO_CLIENT_ID + clientId: process.env.AWS_COGNITO_CLIENT_ID, + refreshInterval: 5 * 60 * 1000, // Set to 0 to disable the browser interval + fetchUserCallback: false // Can be used to put more information into the user object } } - } + } +} ``` diff --git a/package-lock.json b/package-lock.json old mode 100644 new mode 100755 index d9c02df..32831cc --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "@sirdiego/nuxt-auth-cognito-scheme", - "version": "1.0.1", + "version": "1.0.2", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index d0a53aa..1c177f9 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@sirdiego/nuxt-auth-cognito-scheme", - "version": "1.0.1", + "version": "1.0.2", "description": "Use amazon-cognito-identity-js with the Nuxt.js Auth Module.", "main": "index.js", "author": "diego ",