1/* 2jQuery(document).ready(function() { 3 4 gapi.load('auth2', function() { 5 auth2 = gapi.auth2.init({ 6 client_id: 'xxxx.apps.googleusercontent.com', 7 fetch_basic_profile: false, 8 scope: 'profile' 9 }); 10 11 // Sign the user in, and then retrieve their ID. 12 auth2.signIn().then(function() { 13 console.log(auth2.currentUser.get().getId()); 14 }); 15 }); 16}) 17*/ 18 19function google_onSignIn(googleUser) { 20 var profile = googleUser.getBasicProfile(); 21 var id_token = googleUser.getAuthResponse().id_token; 22 23 console.log('ID: ' + profile.getId()); // Do not send to your backend! Use an ID token instead. 24 console.log('Name: ' + profile.getName()); 25 console.log('Image URL: ' + profile.getImageUrl()); 26 console.log('Email: ' + profile.getEmail()); // This is null if the 'email' scope is not present. 27 28 ///////////jQuery('#google-accesstoken').html(id_token); 29 jQuery('.get-google-login-status').html( 30 'å·²ç»å ¥çºï¼' + profile.getName() + 31 '<br>ID: ' + profile.getId() + 32 '<br>Given Name: ' + profile.getGivenName() + 33 '<br>Family Name: ' + profile.getFamilyName() + 34 '<br>Image URL: ' + profile.getImageUrl() + 35 '<br>Email: ' + profile.getEmail()); 36 37 jQuery('.g-login-btn').hide(); 38 jQuery('.g-logout-btn').show(); 39 40 ////setTimeout(function(){ 41 google_social_media_login.user_merge('google', profile.getId(), profile.getEmail(), profile.getName()); 42 ////}, 800); 43} 44 45function _google_signOut() { 46 var auth2 = gapi.auth2.getAuthInstance(); 47 auth2.signOut().then(function() { 48 console.log('Google User signed out.'); 49 document.location.href = "/user/logout"; 50 }); 51} 52 53 54 55/////////////////////////////////////E123 Drupal function//////////////////////////////////////////////////////////// 56google_social_media_login = { 57 user_merge: function(channel, auth_user_id, email, display_name) { 58 if (drupalSettings.user.uid == 0) { 59 var body_data = {} 60 body_data = 61 { 62 "use_method": "web", 63 "channel": channel, 64 "google_id": auth_user_id, 65 "display_name": display_name, 66 "email": email 67 } 68 69 jQuery.ajax({ 70 url: "/api/user/other-channel-merge?_format=json", 71 cache: false, 72 method: "POST", 73 data: JSON.stringify(body_data), 74 headers: {"Accept": "application/json","Content-Type": "application/json","X-CSRF-Token": x_csrf_token }, 75 success: function(data, status, xhr) { 76 console.log("[user_merge] REST API (POST) run via cookie successfully. "); 77 google_social_media_login.login(data['username'], data['pass']); 78 79 }, 80 error: function(data) { 81 console.log(body_data); 82 console.log(data); 83 console.log("[user_merge] REST API (POST) run via cookie failed. "); 84 }, 85 }) 86 } else { 87 console.log("You are already login in drupal! "); 88 } 89 }, 90 91 login: function(username, accesstoken) { 92 if (drupalSettings.user.uid == 0) { 93 var body_data = {} 94 body_data = {'name':username, 'pass': accesstoken} 95 96 jQuery.ajax({ 97 url: "/user/login/?_format=json", 98 cache: false, 99 method: "POST", 100 data: JSON.stringify(body_data), 101 headers: {"Accept": "application/json","Content-Type": "application/json","X-CSRF-Token": x_csrf_token }, 102 success: function(data, status, xhr) { 103 console.log("[Login] REST API (POST) run via cookie successfully. "); 104 location.reload(); 105 }, 106 error: function(data) { 107 console.log(body_data); 108 console.log(data); 109 console.log("[Login] REST API (POST) run via co
109okie failed. "); 110 }, 111 }) 112 } else { 113 console.log("You are already login in drupal! "); 114 } 115 } 116} 117 118jQuery(function($) { 119 $.ajax({ 120 url: "/session/token?_format=json", 121 cache: false, 122 method: "GET", 123 headers: {"Accept": "application/json","Content-Type": "application/json"}, 124 success: function(data, status, xhr) { 125 x_csrf_token = data; 126 }, 127 error: function(data) { 128 console.log("REST API (GET) run via cookie failed. "); 129 }, 130 }) 131});
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.