v1
宇天 2020-09-18 18:29:07 +08:00
parent 11a435bd83
commit d55907d2c7
2 changed files with 9 additions and 4 deletions

3
.gitignore vendored
View File

@ -7,3 +7,6 @@
._* ._*
.idea .idea
.vscode .vscode
node_modules/

View File

@ -6,8 +6,7 @@
*/ */
import Smarty from 'smartyx' //模板引擎 import Smarty from 'smartyx' //模板引擎
import jwt from '@gm5/jwt'
import { sign, verify } from '../module/jwt.js'
const smarty = new Smarty() const smarty = new Smarty()
@ -18,9 +17,12 @@ export default class Controller {
this.request = req this.request = req
this.response = res this.response = res
jwt.expires = ctx.get('session').ttl
jwt.secret = ctx.get('jwt')
this.jwt = { this.jwt = {
sign: sign.bind(this), sign: jwt.sign,
result: verify.call(this) result: jwt.verify(req.header('authorized'))
} }
smarty.config('path', this.ctx.get('VIEWS')) smarty.config('path', this.ctx.get('VIEWS'))