Edit D:\xinhaisoft\crisis_new\api\token\index.js
// ??? const jwt = require('jsonwebtoken') const key = 'f7mqhTPJSyGBzYMU' /** * ????????? */ exports.Sign = data => jwt.sign(data, key, { expiresIn: '12h' }) /** * ???????wt???????????????????????wt????????? */ exports.Verify = (ctx, next) => { const token = ctx.header['authorization'] if (token) { try { const decoded = jwt.verify(token, key) if (typeof next === 'undefined') { return decoded } } catch (err) { throw { code: -3, message: 'Invalid Token' } } // ?????????try??? if (typeof next === 'function') { return new Promise(resolve => resolve(next())) } } else { throw { code: -3, message: 'Authorization Not Found' } } } /** * ??????jwt????????? */ exports.Decode = ctx => { const token = ctx.header['authorization'] if (token) { return jwt.decode(token) } else { throw { code: -3, message: 'Authorization Not Found' } } }
Ms-Dos/Windows
Unix
Write backup
jsp File Browser version 1.2 by
www.vonloesch.de