Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

nuxt auth keep user loggedin on refresh

export default {
  router: {
    middleware: ['auth'],
  },
  modules: [
    '@nuxtjs/auth-next'
  ],
auth: {
  redirect: {
    login: '/login',
    home: '/',
    logout: '/login',
    callback: false, // not used here in our case
  },
  localStorage: false, // REALLY not secure, so nah
  resetOnError: true, // kick the user if any error happens w/ the auth
  strategies: {
    local: {
      scheme: 'refresh', // used for the refreshToken flow
      token: {
        property: 'access_token',
        maxAge: 3600, // only useful if not detected on the login
      },
      refreshToken: {
        property: 'refresh_token',
        data: 'refresh_token',
        maxAge: 60 * 60 * 24 * 30, // 1 month
      },
      clientId: process.env.IAM_CLIENT_ID, // our application's ID aka browser
      user: {
        property: 'employee',
        autoFetch: false, // no need to fetch the user, will be done in gql
      },
      endpoints: {
        login: { url: '/login', method: 'post' },
        refresh: { url: '/oauth/refresh', method: 'post' },
        user: false, // as told above, this one is not needed
        logout: { url: '/logout', method: 'get' },
      },
      tokenRequired: true,
      tokenType: 'JWT',
    },
  },
  plugins: [
    '~/plugins/nuxt-axios.js',
    { src: '~/plugins/nuxt-auth.js', mode: 'client' },
  ],
}
Comment

PREVIOUS NEXT
Code Example
Javascript :: jstl library 
Javascript :: how to create date object with specific time in moment js 
Javascript :: npm hook form 
Javascript :: javascript break and continue 
Javascript :: jquery function done 
Javascript :: js sort integer array 
Javascript :: expresiones regulares javascript 
Javascript :: remove the .cache folder from angular 13 project 
Javascript :: { use UnifiedTopology: true } 
Javascript :: javascript turn negative number to positibve 
Javascript :: Beautifule JS Console Log 
Javascript :: discord js embeded message hyperlink 
Javascript :: javascript string.includes 
Javascript :: User Input from Javascript Console 
Javascript :: prevent click on pseudo element javascript 
Javascript :: remove duplicates from array javascript 
Javascript :: function that duplicates data in array js 
Javascript :: intersection observer api 
Javascript :: jquery fixed element on scroll footer 
Javascript :: js clear map 
Javascript :: MONGOOSE update on by body 
Javascript :: Format of fetch 
Javascript :: get selected option text jquery 
Javascript :: mongoose get value 
Javascript :: javascript check if consecutive array 
Javascript :: update query in mongoose 
Javascript :: upload file on node js azure function 
Javascript :: how to use the foreach method in javascript 
Javascript :: jquery sticky sidebar on scroll 
Javascript :: check web3 metamask disconnect 
ADD CONTENT
Topic
Content
Source link
Name
4+6 =