aboutsummaryrefslogtreecommitdiff
path: root/src/actions/firebase.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/actions/firebase.js')
-rw-r--r--src/actions/firebase.js30
1 files changed, 30 insertions, 0 deletions
diff --git a/src/actions/firebase.js b/src/actions/firebase.js
new file mode 100644
index 0000000..e13ab10
--- /dev/null
+++ b/src/actions/firebase.js
@@ -0,0 +1,30 @@
+import { firebase } from '../firebase.js';
+
+export const AUTH_FAIL = 'AUTH_FAIL';
+export const AUTH_SUCCESS = 'AUTH_SUCCESS';
+
+const auth = firebase.auth();
+
+export const signIn = (_email, _password) => (dispatch) => {
+ auth.signInWithEmailAndPassword(_email, _password).then((user) => {
+ dispatch(authSuccess(user.email));
+ })
+ .catch((error) => {
+ dispatch(authFail(error.code));
+ });
+
+}
+
+export const authFail = (errorCode) => {
+ return {
+ type: AUTH_FAIL,
+ payload: false
+ }
+}
+
+export const authSuccess = (email) => {
+ return {
+ type: AUTH_SUCCESS,
+ payload: true
+ }
+}