'<body>' + '<div id="container">' + ' <h3>Welcome to Session Management Example App, '+( userRecord.displayName || 'N/A') +'</h3>' + ' <div id="loaded">' + ' <div id="main">' + (userRecord.photoURL ? ' <img id="photo" src=' +userRecord.photoURL+ '>' : '') + ' </div>' + ' <div id="name">' + userRecord.displayName + '</div>' + ' <div id="email">'+ userRecord.email + ' (' + (userRecord.emailVerified ? 'verified' : 'unverified') + ')</div>' + ' <div class="clearfix"></div>' + ' </div>' +
functions.auth.user().onDelete((event) => { const uid = event.data.uid; return admin.database().ref(`/users/${uid}`).remove(); })
// send a forgot password email app.post('/api/auth/sendForgotPasswordEmail', (req, res) => { // check if email exists firebase.auth().getUserByEmail(req.body.email) .then(user => { // generate id const resetPasswordID = shortid.generate(); // update user ref releated to provided email ref.child(user.uid).update({ resetPasswordID }); // send email to user email.sendforgotPassword(req.body.email, resetPasswordID, user.uid); }) .catch(err => {}); // catch any error, however we dont notify user // send back success response // send back same response even if no email exists in system due to securtiy res.status(200).json({ success: true, message: 'An e-mail containing instruction on how to reset your password has been sent to the provided email!' }); });
admin.auth().createUser(user).then(function(userRecord) { // See the UserRecord reference doc for the contents of userRecord. console.log("Created User in Authentication, now storing in Realtime Database..."); // Add flag for admin and delete password before storing in RT DB user.is_admin = true; delete user["password"]; var db = admin.database(); var newUserRef = db.ref("users/" + userRecord.uid); newUserRef.set(user, function(error) { if(error) { console.err("Data could not be saved." + error); } else { console.log("Successfully created new user:", userRecord.uid); } process.exit(); }); }).catch(function(error) { console.log("Error creating new user:", error); process.exit(); });
occupation: snapshot.val().settings.occupation, phoneNr: snapshot.val().settings.phoneNr, email: memberRes.email });
const userRef = ref.child(userRecord.uid); const userData = { signupDate, email.sendVerification(req.body.email, verificationID, userRecord.uid); const token = await jwt.sign(userRecord.uid); user: { email: req.body.email, id: userRecord.uid, token, verified: false }, message: 'Successfully created new user', success: true
'<body>' + '<div id="container">' + ' <h3>Welcome to Session Management Example App, '+( userRecord.displayName || 'N/A') +'</h3>' + ' <div id="loaded">' + ' <div id="main">' + (userRecord.photoURL ? ' <img id="photo" src=' +userRecord.photoURL+ '>' : '') + ' </div>' + ' <div id="name">' + userRecord.displayName + '</div>' + ' <div id="email">'+ userRecord.email + ' (' + (userRecord.emailVerified ? 'verified' : 'unverified') + ')</div>' + ' <div class="clearfix"></div>' + ' </div>' +