javascript - Firebase 3 Ionic Email Verification -
i working on ionic application uses firebase 3 baas. application trying implement email verification feature. firebase sending email email template want change url in email node server run "applyactioncode(oobcode)" , set emailverified property user in database true. problem cannot find way send uid if user in email.
here code in ionic -
register: function(formuser) { var d = $q.defer(); auth.$createuserwithemailandpassword(formuser.email, formuser.password) .then(function(user) { $log.log("user created uid: " + user.uid); auth.user = $firebaseobject(usersref.child(user.uid)); auth.user.id = user.uid; auth.user.email = user.email; auth.user.image = user.photourl; auth.user.emailverified = user.emailverified; auth.user.provider = user.providerid; user.sendemailverification(); auth.user.$save().then(function(){ d.resolve(); }).catch(function(error){ console.log("from save "+error); d.reject(error); }); }) .catch(function(error) { $log.log(error); d.reject(error); }); return d.promise; },
this sends out email correctly url -
https://www.mynodeserver/verifyemail?mode=<mode>&oobcode=<code>
this verify email function on node server -
router.get('/verifyemail', function(req, res){ console.log(req.query.oobcode); var oobcode = req.query.oobcode; var apikey = req.query.apikey; var config = { 'serviceaccount': "serviceaccountcredentials.json", 'databaseurl': "https://myappdatabase.firebaseio.com" }; var myapp = firebase.initializeapp(config); var auth = myapp.auth(); auth.applyactioncode(oobcode).then(function(data){ console.log("after action"+data); //set uses emailverified value true here res.json("success!!"); }); });
currently getting auth.applyactioncode() not function. want way tell node server user id can update emailverified value user.
Comments
Post a Comment