@cocalc/server
Version:
CoCalc server functionality: functions used by either the hub and the next.js server
26 lines (25 loc) • 1.1 kB
JavaScript
;
/*
Returns true if the account with given id exists and the password
is correct for the account. Returns false in all other cases.
NOTE: Of course some accounts don't even have a password, in which
case this will always return false.
*/
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const pool_1 = __importDefault(require("@cocalc/database/pool"));
const password_hash_1 = require("@cocalc/backend/auth/password-hash");
async function isPasswordCorrect({ account_id, password, }) {
const pool = (0, pool_1.default)();
const { rows } = await pool.query("SELECT password_hash FROM accounts WHERE account_id=$1", [account_id]);
if (rows.length == 0)
return false;
const { password_hash } = rows[0];
if (!password_hash)
return false;
return (0, password_hash_1.verifyPassword)(password, password_hash);
}
exports.default = isPasswordCorrect;
//# sourceMappingURL=is-password-correct.js.map