Created
July 1, 2018 16:10
-
-
Save localdisk/fdd3251f5fcd86172e2266e35043cd6b to your computer and use it in GitHub Desktop.
Javascript 弱者
This file contains 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'; | |
import firebaseCofnig from '../config/firebase'; | |
let _firebase; | |
let _provider; | |
export default class Auth { | |
static initialize() { | |
if (!_firebase) { | |
_firebase = firebase.initializeApp(firebaseCofnig); | |
_provider = new firebase.auth.TwitterAuthProvider(); | |
_provider.setCustomParameters({ | |
'lang': 'ja' | |
}); | |
} | |
return this; | |
} | |
static login() { | |
return _firebase.auth().signInWithPopup(_provider) | |
.then(result => { | |
return result; | |
}).catch(error => { | |
console.log(error); | |
}); | |
} | |
static 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