Permalink
Browse files

5.3.javascript로 로그인 구현 - 로그인 구현

  • Loading branch information...
egoing committed Aug 26, 2018
1 parent 1e8f226 commit 7a416154ea3921e51d111012d1ef035b7d87ad20
Showing with 25 additions and 1 deletion.
  1. +25 −1 index.html
View
@@ -6,15 +6,26 @@
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script src="colors.js"></script>
<script>
function checkLoginStatus(){
var loginBtn = document.querySelector('#loginBtn');
if(gauth.isSignedIn.get()){
console.log('logined');
loginBtn.value = 'Logout';
} else {
console.log('logouted');
loginBtn.value = 'Login';
}
}
function init(){
console.log('init');
gapi.load('auth2', function() {
console.log('auth2');
var gauth = gapi.auth2.init({
window.gauth = gapi.auth2.init({
client_id:'1069961247398-d5cpi17r74jaad01cf93gbilfnaf3mf4.apps.googleusercontent.com'
})
gauth.then(function(){
console.log('googleAuth success');
checkLoginStatus();
}, function(){
console.log('googleAuth fail');
});
@@ -23,6 +34,19 @@
</script>
</head>
<body>
<input type="button" id="loginBtn" value="checking..." onclick="
if(this.value === 'Login'){
gauth.signIn().then(function(){
console.log('gauth.signIn()');
checkLoginStatus();
});
} else {
gauth.signOut().then(function(){
console.log('gauth.signOut()');
checkLoginStatus();
});
}
">
<h1><a href="index.html">WEB</a></h1>
<input id="night_day" type="button" value="night" onclick="
nightDayHandler(this);

0 comments on commit 7a41615

Please sign in to comment.