meteor - How to ask extra information after login with facebook? -
i have set-up basic meteor application able login facebook. ask valid phone number before creating user. how accomplish in meteor? login workflow :
login-page => click 'login facebook' => user gives permission app => redirect app , ask phone number => create user
i using accounts-facebook , related packages.
thanks
since facebook api doesn't support access user phone, can't extend requestpermission array, ask user_phone.
lets have simple, login facebook button
meteor.loginwithfacebook({ requestpermissions: ['email']}, function (error) { if (error) { return console.log("there error : " error.reason); }else{ //if there no error, lets redirect new user new template router.go('/registerform') } });
now if login successful can redirect user registerform
.
register form html
<template name="registerform"> <!-- simple register form asking phone number --> </template>
js event
template.registerform.events({ 'submit registerform':function(e,t){ //code input value var userphonenumber = t.$('#phoneinputvalue').val() meteor.users.update(meteor.userid(),{$set:{'profile.phonenumber':userphonenumber,'profilenumber':true}}) } })
did se boolean value profilenumber
? can use template helpers ensure , denied access user if dosnt fill registerform
template(just security), can set default on server side using accounts.oncreateuser
method this.
accounts.oncreateuser(function(options, user) { if(!options || !user) { console.log('error creating user'); return; } else { if(options.profile) { user.profile.userphonenumber = false; } } return user; });
Comments
Post a Comment