auth

Main authentication module for my projects
git clone git://git.finwo.net/app/auth
Log | Files | Refs

list.js (818B)


      1 import { app } from '../../../app.js';
      2 import { listUserSessions } from '../../../lib/admin-user-sessions.js';
      3 import { authenticateAdminSession } from '../../../lib/admin-auth.js';
      4 import { parsePagination } from '../../../lib/pagination.js';
      5 
      6 export default {
      7   method: 'get',
      8   path: '/api/v1/admin/users/:userId/sessions',
      9   name: 'admin.userSessionsGlobal.list',
     10   async handler(req) {
     11     const auth = await authenticateAdminSession(req);
     12     const url = new URL(req.url, 'http://localhost');
     13     const pagination = parsePagination(Object.fromEntries(url.searchParams));
     14 
     15     const result = await listUserSessions(auth.systemDb, {
     16       userId: req.params.userId,
     17       actor: auth.user,
     18       realmId: null,
     19       pagination,
     20     });
     21 
     22     return new app.HttpOk(result, { 'cache-control': 'no-store' });
     23   },
     24 };