Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Path: blob/master/src/packages/next/pages/api/v2/accounts/profile.ts
Views: 687
/*1Get the *public* profile for a given account or the private profile of the2user making the request.34This is public information if user the user knows the account_id. It is the5color, the name, and the image.6*/78import getProfile from "@cocalc/server/accounts/profile/get";9import getPrivateProfile from "@cocalc/server/accounts/profile/private";10import getAccountId from "lib/account/get-account";11import getParams from "lib/api/get-params";1213import { apiRoute, apiRouteOperation } from "lib/api";14import {15AccountProfileInputSchema,16AccountProfileOutputSchema,17} from "lib/api/schema/accounts/profile";1819async function handle(req, res) {20const { account_id, noCache } = getParams(req);21try {22if (account_id == null) {23res.json({ profile: await getPrivate(req, noCache) });24} else {25res.json({ profile: await getProfile(account_id, noCache) });26}27} catch (err) {28res.json({ error: err.message });29}30}3132async function getPrivate(req, noCache) {33const account_id = await getAccountId(req, { noCache });34if (account_id == null) {35return {};36}37return await getPrivateProfile(account_id, noCache);38}3940export default apiRoute({41profile: apiRouteOperation({42method: "POST",43openApiOperation: {44tags: ["Accounts"],45},46})47.input({48contentType: "application/json",49body: AccountProfileInputSchema,50})51.outputs([52{53status: 200,54contentType: "application/json",55body: AccountProfileOutputSchema,56},57])58.handler(handle),59});606162