Skip to content

Commit

Permalink
Fix interval clear
Browse files Browse the repository at this point in the history
  • Loading branch information
sirdiego committed May 17, 2020
1 parent 541e2e3 commit a99a470
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 16 deletions.
16 changes: 8 additions & 8 deletions CognitoAuthScheme.js
Original file line number Diff line number Diff line change
Expand Up @@ -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";

Expand All @@ -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,
});
}

Expand Down Expand Up @@ -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");
}
}
Expand All @@ -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),
});
});
}
Expand All @@ -188,5 +188,5 @@ const DEFAULTS = {
userPoolId: undefined,
clientId: undefined,
refreshInterval: 5 * 60 * 1000,
fetchUserCallback: false
fetchUserCallback: false,
};
18 changes: 12 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
}
}
}
```
2 changes: 1 addition & 1 deletion package-lock.json
100644 → 100755

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.1",
"version": "1.0.2",
"description": "Use amazon-cognito-identity-js with the Nuxt.js Auth Module.",
"main": "index.js",
"author": "diego <npmjs@sirdiego.de>",
Expand Down

0 comments on commit a99a470

Please sign in to comment.