Triggering Javascript Code from PHP Laravel Controller -
i'm using oauth login in laravel controller. working fine thing when user registered first time, wanna trigger html 5 geolocation api fetch user's current location , mixpanel stuff. earlier using ajax in js login there no such problem i've implemented complete server side solution, i'm stuck 1 problem.
the laravel controller code looks :
function callback(){ \\ fetch access token , graph data if($res = \auth::mjauthenticate('facebook', $fbdata)){ $user = \auth::scope()->getuser(); return \redirect::to('events'); } if (\auth::mjregister('facebook', $fbdata)) { $user = \auth::scope()->getuser(); return \redirect::to('events'); } return $this->handlefailure('some problem occured'); }
the earlier js code :
ajax .post('auth/login', { data: { oauth_provider: 'facebook', oauth_token: accesstoken }, cache: false }) .done(function(data) { mixpanel.track('user logged in', { id: data.resource.id, provider: 'facebook', email: data.resource.email, first_name: data.resource.first_name, last_name: data.resource.last_name }); if (data.msg == 'resource registered') { if(navigator.geolocation){ // prompt allow deny geolocation popup. } } });
Comments
Post a Comment