Invite System
This commit is contained in:
		
							
								
								
									
										47
									
								
								express-server/public/invite/inv.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										47
									
								
								express-server/public/invite/inv.js
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,47 @@
 | 
			
		||||
$(document).ready(function() {
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
// Initialize Firebase
 | 
			
		||||
var config = {
 | 
			
		||||
    apiKey: "AIzaSyCuvwf78cmSDoZ2yS4XxHZhnjUn7yIHYfw",
 | 
			
		||||
    authDomain: "test-667ca.firebaseapp.com",
 | 
			
		||||
    databaseURL: "https://test-667ca.firebaseio.com",
 | 
			
		||||
    projectId: "test-667ca",
 | 
			
		||||
    storageBucket: "test-667ca.appspot.com",
 | 
			
		||||
    messagingSenderId: "221332577314"
 | 
			
		||||
  };
 | 
			
		||||
 | 
			
		||||
  firebase.initializeApp(config);
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
  var segment_str = window.location.pathname; 
 | 
			
		||||
  var segment_array = segment_str.split( '/' );
 | 
			
		||||
  var last_segment = segment_array.pop();
 | 
			
		||||
 | 
			
		||||
  verifyInvite(last_segment);
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
  function verifyInvite(link) {
 | 
			
		||||
      alert("Ore Link", link)
 | 
			
		||||
    firebase.auth().onAuthStateChanged(function(user){if(user){firebase.auth().currentUser.getIdToken(/* forceRefresh */ true).then(function(idtoken) {
 | 
			
		||||
        $.ajax({
 | 
			
		||||
            type: "POST",
 | 
			
		||||
            url: "/invitemember",
 | 
			
		||||
            data: {
 | 
			
		||||
                idtoken: idtoken,
 | 
			
		||||
                link: link
 | 
			
		||||
            },
 | 
			
		||||
            success(){
 | 
			
		||||
                window.location.href = "/dash/" + idtoken
 | 
			
		||||
            },
 | 
			
		||||
            error(err){
 | 
			
		||||
                console.error("Error: " + err);
 | 
			
		||||
            }
 | 
			
		||||
        });
 | 
			
		||||
    }).catch((error) => console.error("Get id token client error: ", error));}else{console.log("Check Auth error", user)}});
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
});
 | 
			
		||||
 | 
			
		||||
		Reference in New Issue
	
	Block a user