auth

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

membership.js (796B)


      1 import { app } from '../../../app.js';
      2 import { authenticateAdminRequest } from '../../../lib/admin-auth.js';
      3 import { updateAdminRealmMembership } from '../../../lib/admin-users.js';
      4 
      5 export default {
      6   method: 'patch',
      7   path: '/api/v1/admin/realms/:realm/users/:userId/membership',
      8   name: 'admin.users.membership',
      9   async handler(req) {
     10     const auth = await authenticateAdminRequest(req, {
     11       realmSlug: req.params.realm,
     12     });
     13     const result = await updateAdminRealmMembership({
     14       systemDb: auth.systemDb,
     15       realmDb: auth.realmDb,
     16       realm: auth.realm,
     17       userId: req.params.userId,
     18       body: req.body || {},
     19       actor: auth.user,
     20       actorRoles: auth.roles,
     21     });
     22 
     23     return new app.HttpOk({ ok: true, ...result }, { 'cache-control': 'no-store' });
     24   },
     25 };