Skip to content

Commit

Permalink
Merge pull request #35 from baillysi/develop
Browse files Browse the repository at this point in the history
  • Loading branch information
baillysi authored Jul 26, 2024
2 parents b30d936 + a85fc63 commit fa14602
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 4 deletions.
27 changes: 25 additions & 2 deletions src/components/AppHeader.vue
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ onAuthStateChanged(auth, (user) => {
isAuthLoading.value = false
if (user) {
isLoggedIn.value = true
console.log('Successfully logged in !')
console.log('Logged in !')
}
else {
isLoggedIn.value = false
console.log('Successfully logged out!');
console.log('Logged out!');
}
});
Expand All @@ -51,6 +51,29 @@ async function hideLogout() {
// or show error message to the user (account disabled, etc). They can call this API to get that information.
// GetRedirectResult
getRedirectResult(auth)
.then((result) => {
const credential = GithubAuthProvider.credentialFromResult(result);
if (credential) {
// This gives you a GitHub Access Token. You can use it to access the GitHub API.
const token = credential.accessToken;
// ...
}
// The signed-in user info.
const user = result.user;
}).catch((error) => {
// Handle Errors here.
const errorCode = error.code;
const errorMessage = error.message;
alert(error.message)
// The email of the user's account used.
const email = error.email;
// The AuthCredential type that was used.
const credential = GithubAuthProvider.credentialFromError(error);
// ...
});
onMounted(async () => {
isAuthLoading.value = true
})
Expand Down
4 changes: 2 additions & 2 deletions src/components/AuthComponent.vue
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@ const isAuthLoading = ref(false)
const googleProvider = new GoogleAuthProvider()
const githubProvider = new GithubAuthProvider()
// Google provider. Check GetRedirectResult in AppHeader Component to get results.
// Google provider. Check GetRedirectResult in to get results & handle errors.
async function signInWithGoogle() {
isAuthLoading.value = true
await signInWithRedirect(auth, googleProvider)
}
// GitHub provider. Check GetRedirectResult in AppHeader Component to get results.
// GitHub provider. Check GetRedirectResult in to get results & handle errors.
async function signInWithGitHub() {
isAuthLoading.value = true
await signInWithRedirect(auth, githubProvider)
Expand Down

0 comments on commit fa14602

Please sign in to comment.