import getAccountId from "lib/account/get-account";
import getParams from "lib/api/get-params";
import editLicenseOwner from "@cocalc/server/purchases/edit-license-owner";
export default async function handle(req, res) {
try {
res.json(await get(req));
} catch (err) {
res.json({ error: `${err.message}` });
return;
}
}
async function get(req) {
const account_id = await getAccountId(req);
if (account_id == null) {
throw Error("must be signed in");
}
const { license_id, new_account_id } = getParams(req);
await editLicenseOwner({
account_id,
license_id,
new_account_id,
});
return { success: true };
}