2.0
parent
5124566355
commit
458c2b403f
10
index.js
10
index.js
|
@ -12,7 +12,8 @@ function hmac(str, secret) {
|
|||
return base64encode(buf, true)
|
||||
}
|
||||
|
||||
export const jwtPackage = {
|
||||
export function createJwtModule() {
|
||||
return {
|
||||
name: 'jwt',
|
||||
install() {
|
||||
return {
|
||||
|
@ -58,8 +59,10 @@ export const jwtPackage = {
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export function jwtConnect(req, res, next) {
|
||||
export function createJwt() {
|
||||
return function (req, res, next) {
|
||||
var { secret, level } = this.get('jwt')
|
||||
var deviceID = ''
|
||||
var ssid
|
||||
|
@ -83,7 +86,8 @@ export function jwtConnect(req, res, next) {
|
|||
deviceID = sha1(deviceID)
|
||||
}
|
||||
|
||||
req.mixKey = secret + deviceID
|
||||
req.__mix_key__ = secret + deviceID
|
||||
|
||||
next()
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue