verifyHash()
import { createBackendFunction, data, utils } from "@magicjs.dev/backend"; export default createBackendFunction(async function (username, password) { const mongoCollection = data('collectionName'); const user = await mongoCollection.findOne({ username }); if (utils.verifyHash(password, user.password) === false) { // Checking whether the actual password and the user-entered password match. throw new Error(`Password is incorrect`); } else { return "Login succeeded!"; } });
Last updated