Skip to content

Commit

Permalink
[backend] Fix kill all user sessions
Browse files Browse the repository at this point in the history
  • Loading branch information
SouadHadjiat committed Jan 13, 2025
1 parent c999128 commit 5c1e00e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 4 additions & 4 deletions opencti-platform/opencti-graphql/src/database/session.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,8 @@ export const usersWithActiveSessionCount = async (maxInactivityDurationInMin = 1
return sessions.filter((s) => s.isActiveUser).length;
};

export const findUserSessions = async (userId) => {
const sessions = await findSessions({ maxSessionsPerUser: 10 });
export const findUserSessions = async (userId, opts = {}) => {
const sessions = await findSessions(opts);
const userSessions = sessions.filter((s) => s.user_id === userId);
if (userSessions.length > 0) {
return R.head(userSessions);
Expand All @@ -119,8 +119,8 @@ export const killSession = async (id) => {

export const killUserSessions = async (userId) => {
const { store } = applicationSession;
const sessions = await findUserSessions(userId);
const sessionsIds = sessions.map((s) => s.id);
const userSessions = await findUserSessions(userId);
const sessionsIds = userSessions.sessions.map((s) => s.id);
const killedSessions = [];
for (let index = 0; index < sessionsIds.length; index += 1) {
const sessionId = sessionsIds[index];
Expand Down
2 changes: 1 addition & 1 deletion opencti-platform/opencti-graphql/src/resolvers/user.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ const userResolvers = {
groups: (current, args, context) => userGroupsPaginated(context, context.user, current.id, args),
objectOrganization: (current, args, context) => userOrganizationsPaginated(context, context.user, current.id, args),
editContext: (current) => fetchEditContext(current.id),
sessions: (current) => findUserSessions(current.id),
sessions: (current) => findUserSessions(current.id, { maxSessionsPerUser: 10 }),
effective_confidence_level: (current, args, context) => usersConfidenceLoader.load(current, context, context.user),
personal_notifiers: (current, _, context) => getNotifiers(context, context.user, current.personal_notifiers),
},
Expand Down

0 comments on commit 5c1e00e

Please sign in to comment.