diff --git a/src/node/db/SessionManager.js b/src/node/db/SessionManager.js index 67d3e3816..9161205d7 100644 --- a/src/node/db/SessionManager.js +++ b/src/node/db/SessionManager.js @@ -18,13 +18,11 @@ * limitations under the License. */ -var ERR = require("async-stacktrace"); var customError = require("../utils/customError"); var randomString = require("../utils/randomstring"); var db = require("./DB"); var groupManager = require("./GroupManager"); var authorManager = require("./AuthorManager"); -const thenify = require("thenify").withCallback; exports.doesSessionExist = async function(sessionID) { @@ -120,23 +118,19 @@ exports.createSession = async function(groupID, authorID, validUntil) return { sessionID }; } -// @TODO once external dependencies are using Promises -exports.getSessionInfo = thenify(function(sessionID, callback) +exports.getSessionInfo = async function(sessionID) { // check if the database entry of this session exists - db.get("session:" + sessionID, function (err, session) - { - if(ERR(err, callback)) return; + let session = await db.get("session:" + sessionID); - if (session == null) { - // session does not exist - callback(new customError("sessionID does not exist", "apierror")) - } else { - // everything is fine, return the sessioninfos - callback(null, session); - } - }); -}); + if (session == null) { + // session does not exist + throw new customError("sessionID does not exist", "apierror"); + } + + // everything is fine, return the sessioninfos + return session; +} /** * Deletes a session @@ -199,7 +193,7 @@ exports.listSessionsOfAuthor = async function(authorID) // this function is basically the code listSessionsOfAuthor and listSessionsOfGroup has in common // required to return null rather than an empty object if there are none -async function listSessionsWithDBKey(dbkey, callback) +async function listSessionsWithDBKey(dbkey) { // get the group2sessions entry let sessionObject = await db.get(dbkey);