test: dont track session for api/v3 (#12660)

since they get destroyed when the request ends
This commit is contained in:
Barış Soner Uşaklı
2024-06-27 10:26:06 -04:00
committed by GitHub
parent d6c946cf14
commit 61e5293a76
2 changed files with 3 additions and 3 deletions

View File

@@ -342,7 +342,7 @@ authenticationController.doLogin = async function (req, uid) {
await authenticationController.onSuccessfulLogin(req, uid);
};
authenticationController.onSuccessfulLogin = async function (req, uid) {
authenticationController.onSuccessfulLogin = async function (req, uid, trackSession = true) {
/*
* Older code required that this method be called from within the SSO plugin.
* That behaviour is no longer required, onSuccessfulLogin is now automatically
@@ -380,7 +380,7 @@ authenticationController.onSuccessfulLogin = async function (req, uid) {
new Promise((resolve) => {
req.session.save(resolve);
}),
user.auth.addSession(uid, req.sessionID),
trackSession ? user.auth.addSession(uid, req.sessionID) : undefined,
user.updateLastOnlineTime(uid),
user.onUserOnline(uid, Date.now()),
analytics.increment('logins'),

View File

@@ -41,7 +41,7 @@ module.exports = function (middleware) {
async function finishLogin(req, user) {
const loginAsync = util.promisify(req.login).bind(req);
await loginAsync(user, { keepSessionInfo: true });
await controllers.authentication.onSuccessfulLogin(req, user.uid);
await controllers.authentication.onSuccessfulLogin(req, user.uid, false);
req.uid = parseInt(user.uid, 10);
req.loggedIn = req.uid > 0;
return true;