Chat History

Space

"); $("html,body").animate({ scrollTop: 100 }, 1000); } }, failure: function(errMsg) { // console.log(errMsg); } }); } } window.fbAsyncInit = function () { FB.init({ appId: '2016819718806904', xfbml: true, version: 'v18.0' }); FB.AppEvents.logPageView(); }; (function (d, s, id) { var js, fjs = d.getElementsByTagName(s)[0]; if (d.getElementById(id)) { return; } js = d.createElement(s); js.id = id; js.src = "https://connect.facebook.net/en_US/sdk.js"; fjs.parentNode.insertBefore(js, fjs); }(document, 'script', 'facebook-jssdk')); function fb_login() { FB.login(function(response) { if( response.authResponse ) { access_token = response.authResponse.accessToken; user_id = response.authResponse.userID; FB.api('/me', { locale: 'en_US', fields: 'name, email' }, function(response) { if( response != false ) { var post_data = { 'full_name': response.name, 'username': response.email, 'email': response.email, 'fb_id': user_id, 'task': 'signup' }; register( post_data ); } }); } else { $("#message").html("
Error! User cancelled login or did not fully authorize.
"); $("html,body").animate({ scrollTop: 100 }, 1000); } }, { scope: 'email' }); } // Microsoft Login Function function microsoft_login() { const loginRequest = { scopes: ["user.read", "mail.read", "openid", "profile", "email"] }; if (!window.msalInstance) { console.error('MSAL instance not initialized yet.'); return; } // Trigger Microsoft login via Popup window.msalInstance.loginPopup(loginRequest) .then(function (loginResponse) { console.log('Microsoft login successful', loginResponse); const accessToken = loginResponse.accessToken; fetchUserProfile(accessToken); }) .catch(function (error) { console.error('Microsoft login failed', error); //alert('Login failed'); $("#message").html("
Error! Microsoft login failed.
"); $("html,body").animate({ scrollTop: 100 }, 1000); }); } // Fetch User Profile from Microsoft Graph API function fetchUserProfile(accessToken) { fetch('https://graph.microsoft.com/v1.0/me', { method: 'GET', headers: { 'Authorization': 'Bearer ' + accessToken } }) .then(response => response.json()) .then(data => { console.log('User Profile:', data); var post_data = { 'full_name': data.displayName, 'username': data.userPrincipalName, 'email': data.mail || data.userPrincipalName, // Fallback if mail is null 'ms_id': data.id, // Microsoft's unique user ID 'task': 'signup' // Indicate whether it's a new signup or login }; register(post_data); }) .catch(err => { console.error('Error fetching user profile', err); $("#message").html("
Error! Error fetching user profile.'
"); $("html,body").animate({ scrollTop: 100 }, 1000); //alert('Error fetching profile'); }); } // Initialize Apple Sign-In AppleID.auth.init({ clientId: "com.search.login", redirectURI: 'https://search.com', //state: "random_string", // CSRF protection usePopup: true }); function apple_login() { AppleID.auth.signIn().then(function (response) { let id_token = response.authorization.id_token; // Decode JWT Token in frontend (Base64) let user_data = parseJwt(id_token); var post_data = { 'email': user_data.email, 'app_id': user_data.sub, // Apple's unique user ID 'task': 'signup' // Indicate whether it's a new signup or login }; let fullName = response.user ? response.user.name : null; if (fullName) { post_data["full_name"] = fullName.firstName + " " + fullName.lastName; } register(post_data); }).catch(function (error) { console.error("Apple Sign-In Error:", error); $("#message").html("
Error! Error fetching user profile.
"); $("html,body").animate({ scrollTop: 100 }, 1000); }); } // Function to Decode Apple ID Token (JWT) function parseJwt(token) { try { let base64Url = token.split('.')[1]; let base64 = base64Url.replace(/-/g, '+').replace(/_/g, '/'); return JSON.parse(atob(base64)); } catch (e) { return null; } }

GPTs

Explore and discover powerful SearchGPT tools that help you create, organize, and personalize your experience like never before.

Sign Up for Free

Unlock Pro Search and History

Continue with Google

logo
tab