Created
June 30, 2018 10:26
-
-
Save localdisk/a8d5b4d4003bba90951fd36b3debb8fd to your computer and use it in GitHub Desktop.
雑な Firebase Twitter login
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import firebase from 'firebase/app'; | |
import 'firebase/auth'; | |
//export default Object.assign({}, { | |
// apiKey: process.env.MIX_FIREBASE_API_KEY, | |
// authDomain: process.env.MIX_FIREBASE_AUTH_DOMAIN, | |
//}); | |
// ↑は config/firebase の内容 | |
import firebaseCofnig from '../config/firebase'; | |
export default class Auth { | |
constructor() { | |
this.firebase = firebase.initializeApp(firebaseCofnig); | |
this.provider = new firebase.auth.TwitterAuthProvider(); | |
this.provider.setCustomParameters({ | |
'lang': 'ja' | |
}); | |
} | |
login() { | |
return this.firebase.auth().signInWithPopup(this.provider) | |
.then(result => { | |
return result; | |
}).catch(error => { | |
console.log(error); | |
}); | |
} | |
logout() { | |
firebase.auth().signOut() | |
.then(result => { | |
console.log('logout.'); | |
}) | |
.catch(error => { | |
console.log(error); | |
}); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment