auth

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

get.js (716B)


      1 import { app } from '../../../app.js';
      2 import { authenticateAdminSession } from '../../../lib/admin-auth.js';
      3 import { getAdminGlobalUserOverview } from '../../../lib/admin-users.js';
      4 import { HttpError } from '../../../lib/http/http-error.js';
      5 
      6 export default {
      7   method: 'get',
      8   path: '/api/v1/admin/users/:userId',
      9   name: 'admin.users.get_global',
     10   async handler(req) {
     11     const auth = await authenticateAdminSession(req);
     12     const user = await getAdminGlobalUserOverview(
     13       auth.systemDb,
     14       auth.user,
     15       req.params.userId
     16     );
     17     if (!user) {
     18       throw new HttpError(404, 'user_not_found', 'User not found');
     19     }
     20 
     21     return new app.HttpOk(user, { 'cache-control': 'no-store' });
     22   },
     23 };