Comparing version 3.0.2 to 3.0.3-alpha.1
@@ -187,4 +187,11 @@ "use strict"; | ||
fallback = async (ctx, next) => { | ||
// verify | ||
const token = ctx.cookies.get(this.authCookieName); | ||
// 优先从 cookie 中获取 token | ||
let token = ctx.cookies.get(this.authCookieName); | ||
let setCookie = true; | ||
// 如果没有 token,则从 header 中获取 | ||
if (!token) { | ||
token = ctx.get(this.authCookieName); | ||
// 如果从 header 中获取到 token,则不再设置 cookie | ||
setCookie = !token; | ||
} | ||
let sub; | ||
@@ -203,5 +210,7 @@ if (this.authHandler) { | ||
await this.authHandler(ctx, sub); | ||
const refreshedToken = this.subjectProvider.refresh(token); | ||
if (refreshedToken) { | ||
this.saveJsonWebTokenToHeader(ctx, refreshedToken); | ||
if (setCookie) { | ||
const refreshedToken = this.subjectProvider.refresh(token); | ||
if (refreshedToken) { | ||
this.saveJsonWebTokenToHeader(ctx, refreshedToken); | ||
} | ||
} | ||
@@ -222,5 +231,7 @@ } | ||
this.saveAuthenticationInformationToContext(ctx, authenticationInformation); | ||
const refreshedToken = this.jwtProvider.refresh(token); | ||
if (refreshedToken) { | ||
this.saveJsonWebTokenToHeader(ctx, refreshedToken); | ||
if (setCookie) { | ||
const refreshedToken = this.jwtProvider.refresh(token); | ||
if (refreshedToken) { | ||
this.saveJsonWebTokenToHeader(ctx, refreshedToken); | ||
} | ||
} | ||
@@ -227,0 +238,0 @@ } |
{ | ||
"name": "egg-kauth", | ||
"version": "3.0.2", | ||
"version": "3.0.3-alpha.1", | ||
"description": "egg kauth plugin", | ||
@@ -5,0 +5,0 @@ "eggPlugin": { |
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
28650
662
2