1
Good morning! I used the google login API on a website page. It takes the information and works correctly, however, even without clicking the button, it already runs the js of google directly, without making it possible somehow to do the "singOut" of the system because whenever I go to the login page, it already automatically picks up the information and goes to the redirect page. Follow the code from the login page
<div class="g-signin2" data-onsuccess="onSignIn" data-theme="dark" style="width: 350px"></div>
<script>
function onSignIn(googleUser) {
var profile = googleUser.getBasicProfile();
var userID = profile.getId();
var userName = profile.getName();
var userPicture = profile.getImageUrl();
var userEmail = profile.getEmail();
var userToken = googleUser.getAuthResponse().id_token;
//document.getElementById('msg').innerHTML = userEmail;
if(userEmail !== ''){
var dados = {
userID:userID,
userName:userName,
userPicture:userPicture,
userEmail:userEmail
};
$.post('validarLoginGoogle.php', dados, function(retorna){
if(retorna=="1"){
window.location.href = "http://calangoeventos.eu5.net/telas/telaInicial.php";
}
}else{
window.location.href = "http://calangoeventos.eu5.net/telas/complementoCadastro.php";
}
});
}
}
</script>
The purpose of the above code is to redirect the user to the home page if he has already accessed before and if not, redirect to the registration add-on screen And the code of my validarLoginGoogle.php
<?php
session_start();
include_once("../funcoes/integracaoBanco.php");
$email = filter_input(INPUT_POST, 'userEmail', FILTER_SANITIZE_STRING);
$name = filter_input(INPUT_POST, 'userName', FILTER_SANITIZE_STRING);
$result_usuario = "SELECT * FROM Usuario WHERE email='$email'";
$resultado_usuario = mysqli_query($conexao, $result_usuario);
//Econtrado usuario com esse e-mail
if(($resultado_usuario) AND ($resultado_usuario->num_rows != 0)){
$user = mysqli_fetch_assoc($resultado_usuario);
$_SESSION['usuarioLogado'] = $user;
$result = 1;
echo(json_encode($result));
}else{//Nenhum usuário encontrado
$result = 2;
echo(json_encode($result));
}
and if you include a button or link to make the Sign out?
– Ricardo Pontual
My Sign out only destroys user session after logged in, searched Sign out on api but found nothing related.
– Amanda Briena
but in fact the problem is not exactly Sign out but rather control so that it just Logs on the system when click on the Google in Sign button and not automatically picking up the information that had been generated previously.
– Amanda Briena