优化jwt验证方式
parent
655c5e34fa
commit
7fbf720e62
4
index.js
4
index.js
|
@ -30,10 +30,10 @@ export default class Controller {
|
||||||
let { __mix_key__ } = this.request
|
let { __mix_key__ } = this.request
|
||||||
return this.context.$$jwt.sign(data, __mix_key__)
|
return this.context.$$jwt.sign(data, __mix_key__)
|
||||||
},
|
},
|
||||||
verify: () => {
|
verify: token => {
|
||||||
this.#auth = null
|
this.#auth = null
|
||||||
let token = this.request.header('authorization')
|
|
||||||
let { __mix_key__ } = this.request
|
let { __mix_key__ } = this.request
|
||||||
|
token ??= this.request.header('authorization')
|
||||||
|
|
||||||
if (token) {
|
if (token) {
|
||||||
this.#auth = this.context.$$jwt.verify(token, __mix_key__)
|
this.#auth = this.context.$$jwt.verify(token, __mix_key__)
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "@gm5/controller",
|
"name": "@gm5/controller",
|
||||||
"version": "2.0.2",
|
"version": "2.0.3",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"description": "控制器基类。",
|
"description": "控制器基类。",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
|
|
Loading…
Reference in New Issue