Skip to content

Instantly share code, notes, and snippets.

@earth774
Created April 11, 2019 10:07
Show Gist options
  • Save earth774/d222a92ad39033c84fd84aff0586db1c to your computer and use it in GitHub Desktop.
Save earth774/d222a92ad39033c84fd84aff0586db1c to your computer and use it in GitHub Desktop.
did login google
<template>
<div class="hello">
<h1>{{ msg }}</h1>
<button @click="socialGoogleLogin">Google</button>
<button>Facebook</button>
</div>
</template>
<script>
import firebase from "firebase";
export default {
name: "HelloWorld",
props: {
msg: String
},
methods: {
socialGoogleLogin: function() {
const provide = new firebase.auth.GoogleAuthProvider().addScope("email");
firebase
.auth()
.signInWithPopup(provide)
.then(result => {
// create user in db
let obj = {
google_id: result.additionalUserInfo.profile.id,
fullname: result.additionalUserInfo.profile.name,
email: result.additionalUserInfo.profile.email,
profile_image: result.additionalUserInfo.profile.picture,
user_type_id: 1
};
console.log(obj);
})
.catch(err => {
alert("Oops. " + err.message);
});
}
}
};
</script>
<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>
h3 {
margin: 40px 0 0;
}
ul {
list-style-type: none;
padding: 0;
}
li {
display: inline-block;
margin: 0 10px;
}
a {
color: #42b983;
}
</style>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment