Fix authorization renewal

This commit is contained in:
Sulka Haro
2020-12-21 21:09:18 +02:00
parent 4bdd271939
commit edfcf6eccd
4 changed files with 15 additions and 9 deletions
+9 -2
View File
@@ -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);