// validate and verify user account app.post('/api/auth/verifyAccount', (req, res) => { // check if id and verify code is present const verifyRef = db.ref(`users/${req.body.userID}/verificationID`); verifyRef.once('value', snapshot => { // check if code exists or is not valid if (!snapshot.exists() || snapshot.val() !== req.body.verificationID) { return res.status(400).json({ success: false, message: 'The verification code is removed or might never existed.' }); } // verify account and remove verify ref to no longer exist firebase.auth().updateUser(req.body.userID, { emailVerified: true }); verifyRef.remove(); // send back success response res.status(200).json({ success: true, message: 'Thanks! Your account was successfully verified.' }); }); });
firebase.auth().updateUser(req.body.userID, { password: req.body.password })