This commit is contained in:
李科 2019-08-28 14:25:56 +08:00
parent b630fb7ef8
commit 308c0f8af1
2 changed files with 13 additions and 1 deletions

View File

@ -29,7 +29,7 @@ AuthToken.prototype.genToken = async function(userData, expiresSeconds) {
userData: userData, userData: userData,
expires: {ttl: expiresSeconds, ts: Math.floor(Date.now() / 1000)} expires: {ttl: expiresSeconds, ts: Math.floor(Date.now() / 1000)}
}; };
this.tokenDB.set(userToken, JSON.stringify(tokenData), 'EX', expiresSeconds); await this.tokenDB.set(userToken, JSON.stringify(tokenData), 'EX', expiresSeconds);
return userToken; return userToken;
}; };

12
auth/test.js Normal file
View File

@ -0,0 +1,12 @@
/**
* 作者:likeagle@163.com,
* 功能:
**/
"use strict";
const r = {"host": "101.200.241.0", "port": 6379, "password": "ehason"};
const a = require('./index')(r);
a.genToken({name: 'u', sex: 'm'}, 100).then( t =>{
console.log(t);
});