Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // User is signed in.
- userId=user.uid;
- //alert(userId);
- var date = new Date();
- var n = date.toDateString();
- var time = date.toLocaleTimeString();
- datetime=n+" "+time;
- snapcity="";
- check(userId,snapcity); //data retrieval function
- var database = firebase.database();
- writeUserData(userId,ajaxData.geoplugin_request,ajaxData.geoplugin_city,datetime);
- document.getElementById("user_div").style.display = "block";
- document.getElementById("login_div").style.display = "none";
- var user = firebase.auth().currentUser;
- if(user != null){
- var email_id = user.email;
- document.getElementById("user_para").innerHTML = "Welcome User : " + email_id;
- console.log('data');
- console.log(ajaxData);
- html="<p>ip: "+ajaxData.geoplugin_request+"</p><p>Country Code: +44</p><p>Country: "+ajaxData.geoplugin_countryName+"</p><p>Country Abbrevation: "+ajaxData.geoplugin_countryCode+"</p><p>Region Code: "+ajaxData.geoplugin_regionCode+"</p><p>Region Name: "+ajaxData.geoplugin_regionName+"</p><p>City: "+ajaxData.geoplugin_city+"</p><p>Time Zone: "+ajaxData.geoplugin_timezone+"</p><p>Latitude: "+ajaxData.geoplugin_latitude+"</p><p>Longitude: "+ajaxData.geoplugin_longitude+"</p><p>Last Login: "+datetime+"</p>";
- $('#data').html(html);
- }
- } else {
- // No user is signed in.
- document.getElementById("user_div").style.display = "none";
- document.getElementById("login_div").style.display = "block";
- }
- });
- function check(userId,snapcity){
- var rootRef=firebase.database().ref().child('users');
- rootRef.on('child_added', function(snap){
- if(snap.child("userId").val()==userId){
- snapcity=snap.child("city").val();
- }
- });
- console.log(snapcity);
- console.log(ajaxData.geoplugin_city);
- if(snapcity){
- if(snapcity!=ajaxData.geoplugin_city){
- logout();
- alert("you can't login because previously you were logged from "+snapcity );
- }
- }
- }
Add Comment
Please, Sign In to add comment