更新
This commit is contained in:
@@ -0,0 +1,17 @@
|
||||
const jwt = require("jsonwebtoken");
|
||||
const config = require("./config.js");
|
||||
|
||||
module.exports = {
|
||||
/**
|
||||
* 签发token
|
||||
* @param {object} data 加入到签名里的数据.
|
||||
* @return {string} token 令牌.
|
||||
*/
|
||||
sign: (data) => jwt.sign(data, config.secret, {algorithm: config.algorithm, expiresIn: config.expiresIn}),
|
||||
/**
|
||||
* 验证token
|
||||
* @param {string} token 令牌.
|
||||
* @return {boolean} 验证通过返回true.
|
||||
*/
|
||||
verify: (token) => jwt.verify(token, config.secret, {algorithm: config.algorithm, expiresIn: config.expiresIn}),
|
||||
}
|
||||
Reference in New Issue
Block a user