You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
18 lines
326 B
JavaScript
18 lines
326 B
JavaScript
3 years ago
|
const JWT=require("jsonwebtoken");
|
||
|
const auth={
|
||
|
secret:"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9",
|
||
|
token(data){
|
||
|
return JWT.sign({data},this.secret,{
|
||
|
expiresIn:"1d"
|
||
|
})
|
||
|
},
|
||
|
decode(token){
|
||
|
try {
|
||
|
return JWT.verify(token,this.secret);
|
||
|
}catch (e) {
|
||
|
return null
|
||
|
}
|
||
|
}
|
||
|
};
|
||
|
module.exports=auth;
|