Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion lib/plugin.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
/* eslint-disable import/no-unresolved, import/no-extraneous-dependencies, prefer-template */
import middleware from '@@/.nuxt/middleware'

// ToDo: TTL hardcoded
const TOKEN_TIME_TO_LIVE = 2 * 60 * 1000 // 2 minutes
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where is this value coming from?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should probably come from identity service, for now token lives 2min, usually should be 2h

const moduleName = '<%= options.moduleName %>'

const initStore = async context => {
Expand All @@ -15,11 +17,15 @@ const initStore = async context => {
namespaced: true,
state: {
accessToken: (context.req && context.req.accessToken),
user: (context.req && context.req.user)
user: (context.req && context.req.user),
expiryDate: new Date(new Date().getTime() + TOKEN_TIME_TO_LIVE)
},
mutations: {
setAccessToken (state, accessToken) {
state.accessToken = accessToken
},
setTokenExpiry (state, expiryDate) {
state.expiryDate = expiryDate
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "nuxt-oauth",
"version": "2.10.0",
"version": "2.10.2",
"description": "OAuth module for your Nuxt applications",
"main": "index.js",
"repository": "https://github.com/SohoHouse/nuxt-oauth",
Expand Down