Skip to content

Instantly share code, notes, and snippets.

@localdisk
Created July 1, 2018 16:10
Show Gist options
  • Save localdisk/fdd3251f5fcd86172e2266e35043cd6b to your computer and use it in GitHub Desktop.
Save localdisk/fdd3251f5fcd86172e2266e35043cd6b to your computer and use it in GitHub Desktop.
Javascript 弱者
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