隐藏登录谷歌's "欢迎回来,{name}"

Hiding Sign In With Google's "Welcome back, {name}"

本文关键字:quot 欢迎回来 name 登录 谷歌 隐藏      更新时间:2023-09-26

如何使欢迎返回消息不会在每次用户导航到新页面时出现?

有问题的消息

编辑:添加了代码,但它的所有基本的东西,以获得用户登录。

回调:

function signInCallback(authResult) {
  gapi.client.load('plus','v1', function(){
    if (authResult['status']['signed_in']) {
    // Update the app to reflect a signed in user
    // Hide the sign-in button now that the user is authorized, for example:
      $('#gConnect').hide();
      $('#authOps').show('slow');
       setProfileInfo(firstName);
       isUserInDatabase();
    console.log(authResult);
  } else {
    // Update the app to reflect a signed out user
    // Possible error values:
    //   "user_signed_out" - User is signed-out
    //   "access_denied" - User denied access to your app
    //   "immediate_failed" - Could not automatically log in the user
    console.log('Sign-in state: ' + authResult['error']);
  }
});
}

登录按钮:

<div id="gConnect">
    <button class="g-signin"
        data-scope="https://www.googleapis.com/auth/plus.login https://www.googleapis.com/auth/plus.profile.emails.read"
        data-requestvisibleactions="http://schemas.google.com/AddActivity"
        data-clientId="819876183778-b7cuojcnn2fsi1rcm9k8sshnsebic68e.apps.googleusercontent.com"
        data-callback="signInCallback"
        data-theme="dark"
        data-cookiepolicy="single_host_origin">
    </button>
  </div>

加载Google+ API:

<script type="text/javascript">
  (function() {
    var po = document.createElement('script');
    po.type = 'text/javascript'; po.async = true;
    po.src = 'https://plus.google.com/js/client:plusone.js';
    var s = document.getElementsByTagName('script')[0];
    s.parentNode.insertBefore(po, s);
  })();
  </script>

所以我建议跟踪用户的已登录状态(本地存储或服务器端标志),并且仅在状态从未登录更改为已登录时显示消息