mirror of
https://github.com/bckelley/cgm-remote-monitor.git
synced 2026-08-24 03:14:12 -05:00
Fix authorization renewal
This commit is contained in:
@@ -275,11 +275,18 @@ function init (env, ctx) {
|
||||
*/
|
||||
authorization.authorize = function authorize (accessToken) {
|
||||
|
||||
var subject = storage.findSubject(accessToken);
|
||||
let userToken = accessToken
|
||||
const decodedToken = jwt.decode(accessToken);
|
||||
|
||||
if (decodedToken && decodedToken.accessToken) {
|
||||
userToken = decodedToken.accessToken;
|
||||
}
|
||||
|
||||
var subject = storage.findSubject(userToken);
|
||||
var authorized = null;
|
||||
|
||||
if (subject) {
|
||||
var token = jwt.sign({ accessToken: subject.accessToken }, env.api_secret, { expiresIn: '1h' });
|
||||
var token = jwt.sign({ accessToken: subject.accessToken }, env.api_secret, { expiresIn: '8h' });
|
||||
|
||||
//decode so we can tell the client the issued and expired times
|
||||
var decoded = jwt.decode(token);
|
||||
|
||||
Reference in New Issue
Block a user