Closed LukasHirt closed 2 years ago
module: 5.0.0-1624817847.21691f1 nuxt: 2.15.7
auth: { cookie: false, redirect: { login: '/sign-in', }, strategies: { local: { scheme: '@/schemes/auth-refresh-token', token: { property: 'accessToken', maxAge: 900, global: true, type: 'Bearer', }, refreshToken: { property: 'refreshToken', data: 'refreshToken', maxAge: 60 * 60 * 24 * 30, }, user: { property: false, }, endpoints: { login: { url: '/auth/login', method: 'post' }, refresh: { url: '/auth/refresh-token', method: 'post' }, user: { url: '/users/profile', method: 'get' }, logout: false, }, }, }, },
import { RefreshScheme, ExpiredAuthSessionError } from '@nuxtjs/auth-next/dist/runtime' function cleanObj(obj) { for (const key in obj) { if (obj[key] === 0) { delete obj[key]; } } return obj; } export default class CustomRefreshScheme extends RefreshScheme { async refreshTokens() { if (!this.options.endpoints.refresh) { return Promise.resolve(); } if (!this.check().valid) { return Promise.resolve(); } const refreshTokenStatus = this.refreshToken.status(); if (refreshTokenStatus.expired()) { this.$auth.reset(); throw new ExpiredAuthSessionError(); } if (!this.options.refreshToken.tokenRequired) { this.requestHandler.clearHeader(); } const endpoint = { data: { client_id: 0, grant_type: 0 } }; if (this.options.refreshToken.required && this.options.refreshToken.data) { endpoint.data[this.options.refreshToken.data] = this.refreshToken.get(); } if (this.options.clientId) { endpoint.data.client_id = this.options.clientId; } if (this.options.grantType) { endpoint.data.grant_type = "refresh_token"; } const userEmail = this.$auth.user.email if (userEmail) { endpoint.data.email = userEmail } cleanObj(endpoint.data); try { const response = await this.$auth.request(endpoint, this.options.endpoints.refresh); this.updateTokens(response, { isRefreshing: true }); return response; } catch (error) { this.$auth.callOnError(error, { method: "refreshToken" }); return await Promise.reject(error); } } }
Cookie is not set
Auth cookies storing strategy, token, etc. are still being set
Set cookie: false in the auth config.
cookie: false
Fixed in #1436
Thank you! Just correcting the PR number - #1442
Oh sorry 😄
Version
module: 5.0.0-1624817847.21691f1 nuxt: 2.15.7
Nuxt configuration
mode:
Nuxt configuration
Custom scheme
What is expected?
Cookie is not set
What is actually happening?
Auth cookies storing strategy, token, etc. are still being set
Steps to reproduce
Set
cookie: false
in the auth config.Checklist