"use strict";
/*
Set password for an existing account.
*/
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const set_password_1 = __importDefault(require("@cocalc/server/accounts/set-password"));
const get_account_1 = __importDefault(require("lib/account/get-account"));
const get_params_1 = __importDefault(require("lib/api/get-params"));
async function handle(req, res) {
    const account_id = await (0, get_account_1.default)(req);
    if (account_id == null) {
        res.json({ error: "must be signed in" });
        return;
    }
    const { currentPassword, newPassword } = (0, get_params_1.default)(req);
    try {
        await (0, set_password_1.default)(account_id, currentPassword, newPassword);
        res.json({});
    }
    catch (err) {
        res.json({ error: err.message });
    }
}
exports.default = handle;
//# sourceMappingURL=set-password.js.map