Skip to main content
Glama
revoke.ts1.19 kB
// SPDX-FileCopyrightText: Copyright Orangebot, Inc. and Medplum contributors // SPDX-License-Identifier: Apache-2.0 import { allOk, notFound } from '@medplum/core'; import type { Login } from '@medplum/fhirtypes'; import type { Request, Response } from 'express'; import { body } from 'express-validator'; import { getAuthenticatedContext } from '../context'; import { sendOutcome } from '../fhir/outcomes'; import { getSystemRepo } from '../fhir/repo'; import { revokeLogin } from '../oauth/utils'; import { makeValidationMiddleware } from '../util/validator'; export const revokeValidator = makeValidationMiddleware([ body('loginId').isUUID().withMessage('Login ID is required.'), ]); export async function revokeHandler(req: Request, res: Response): Promise<void> { const ctx = getAuthenticatedContext(); const systemRepo = getSystemRepo(); const login = await systemRepo.readResource<Login>('Login', req.body.loginId); // Make sure the login belongs to the current user if (login.user?.reference !== ctx.membership.user?.reference) { sendOutcome(res, notFound); return; } // Mark the login as revoked await revokeLogin(login); sendOutcome(res, allOk); }

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/medplum/medplum'

If you have feedback or need assistance with the MCP directory API, please join our Discord server