Skip to content

Commit

Permalink
Update index.html
Browse files Browse the repository at this point in the history
  • Loading branch information
momentollogy committed Apr 13, 2023
1 parent 3a041a0 commit 510585a
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ <h1>Arduino Piano Buzzer Song Creator V1 <br> <small>by momentollogy</small><br>
const token = googleUser.getAuthResponse().id_token;
gapi.load('client', () => {
initClient(token).then(() => {
updateSignInStatus();
updateSignInStatus(googleUser);
});
});
}
Expand All @@ -144,25 +144,26 @@ <h1>Arduino Piano Buzzer Song Creator V1 <br> <small>by momentollogy</small><br>
auth2.signOut().then(() => {
console.log('User signed out.');
gapi.client = null;
updateSignInStatus();
updateSignInStatus(null);
});
}

function updateSignInStatus() {
const authInstance = gapi.auth2.getAuthInstance();
const isSignedIn = authInstance.isSignedIn.get();
function updateSignInStatus(googleUser) {
const signInButton = document.getElementById('signinButton');

if (isSignedIn) {
if (googleUser) {
signInButton.innerText = 'Sign Out';
signInButton.onclick = signOut;
} else {
signInButton.innerText = 'Sign In';
signInButton.onclick = onSignIn;
signInButton.onclick = () => {
gapi.auth2.getAuthInstance().signIn().then(onSignIn);
};
}
}



async function initClient(token) {
await gapi.load('client:auth2', async () => {
try {
Expand Down

0 comments on commit 510585a

Please sign in to comment.