0

사용자가 Google 로그인을 사용하여 사이트에 로그인 할 수있게 해주는 기본 웹 사이트를 작성 중입니다. 나는 파이어베이스를 통해 이것을 시도했으며 지금까지 성공적인 결과를 얻었습니다. 그들의 문서에서 사용자는 firebase 실시간 데이터베이스의 변수 "auth"에 저장되고 전자 메일과 사용자 ID는 변수에서 액세스 할 수 있습니다. 필자는 예제 파일을 지침으로 사용하는 것뿐만 아니라 문서의 모든 단계를 따랐습니다. 내 계정 제어판에 내 사이트에 로그인하는 모든 사용자와 사용자 ID 및 전자 메일 주소가 기록됩니다. 그러나 실시간 데이터베이스 탭에서는 그렇지 않습니다. 사용자가 로그인 한 횟수에 관계없이 데이터베이스는 공백으로 남아 있습니다. 이렇게하려면 사용자의 이메일 주소에 액세스 할 수 있어야하므로 중요한 문제가됩니다. 웹 페이지에 표시하는 것과 같은 것들.Google 로그인 사용자가 데이터베이스 로그에 나타나지 않음

<html> 
    <head> 
    <title>SEatAMRS auth test</title> 
    <script src="https://www.gstatic.com/firebasejs/3.2.0/firebase.js"></script> 
    <script type="text/javascript"> 

    // Initialize Firebase 
    var config = { 
    apiKey: "****************2XqEQSO9Z8vhPF5w", 
    authDomain: "*********-build.firebaseapp.com", 
    databaseURL: "https://***********-build.firebaseio.com", 
    storageBucket: "***********-build.appspot.com", 
    }; 

    firebase.initializeApp(config); 

    //Creatse a provider object 
    var provider = new firebase.auth.GoogleAuthProvider(); 

    firebase.auth().signInWithPopup(provider).then(function(result) { 
    // This gives you a Google Access Token. You can use it to access the Google API. 
    var token = result.credential.accessToken; 
    // The signed-in user info. 
    var user = result.user; 
    // ... 
}).catch(function(error) { 
    // Handle Errors here. 
    var errorCode = error.code; 
    var errorMessage = error.message; 
    // The email of the user's account used. 
    var email = error.email; 
    // The firebase.auth.AuthCredential type that was used. 
    var credential = error.credential; 
    // ... 
}); 

    //Sign out function 
    firebase.auth().signOut().then(function() { 
    // Sign-out successful. 
}, function(error) { 
    // An error happened. 
}); 

    </script> 

    </head> 

    <body> 
    <h1>Welcome to the Google Sign in Fucntionality Test!</h1> 
</html> 
+0

사용자 정보가 자동으로 데이터베이스에 저장되지 않습니다. 코드 및 데이터베이스의 보안 규칙에서 사용할 수 있습니다. 데이터베이스에 정보를 저장하려면 자신의 코드에서 그렇게 할 수 있습니다. https://stackoverflow.com/questions/14673708/how-do-i-return-a-list-of-users-if-use-the-firebase-simple-username-password 및 Google의 유산에서 본 예제를 참조하십시오. docs : https://www.firebase.com/docs/web/guide/user-auth.html#section-storing –

답변

0

먼저 당신이 사용자에서 사용자 이름과 비밀번호를 가져와 다음과 같이

내가 작성한 코드입니다. 그런 다음 html로 자격 증명의 유효성을 검사 한 다음 firebase에 signin 메소드를 사용합니다.

+0

이 코드는 사용자가 Google 계정 자격 증명을 입력 할 수있는 팝업을 제공하므로 이를 인증하고 Google 계정에서 사이트에 로그인 할 수 있도록합니다. 내가 추가 한 기능은 예상대로 작동합니다. 사용자가 데이터베이스에 저장되지 않는다는 사실은 firebase 설명서에 나와 있습니다. – WebGavDev

관련 문제