From df84c80899e4f7a0689a003fa9974243453f8ee8 Mon Sep 17 00:00:00 2001 From: Qolzam Date: Sat, 21 Oct 2017 11:08:41 +0700 Subject: [PATCH] Remove unnecessary files for authorization --- app/api/AuthAPI.jsx | 16 ---------------- app/api/AuthRouterAPI.jsx | 30 ------------------------------ app/components/Blog.jsx | 1 - app/components/PostWrite.jsx | 1 - app/components/Sidebar.jsx | 1 - app/helpers/index.jsx | 29 ----------------------------- 6 files changed, 78 deletions(-) delete mode 100644 app/api/AuthAPI.jsx delete mode 100644 app/api/AuthRouterAPI.jsx delete mode 100644 app/helpers/index.jsx diff --git a/app/api/AuthAPI.jsx b/app/api/AuthAPI.jsx deleted file mode 100644 index ab7c2bf..0000000 --- a/app/api/AuthAPI.jsx +++ /dev/null @@ -1,16 +0,0 @@ -// - Import firebase components -import {firebaseAuth, firebaseRef} from 'app/firebase/' -import store from 'store/configureStore' - -// - Check user if is authorized -export let isAuthorized = () => { - let state = store.getState() - return state.authorize.authed - -} - -export let isAdmin = () =>{ - -return true - -} diff --git a/app/api/AuthRouterAPI.jsx b/app/api/AuthRouterAPI.jsx deleted file mode 100644 index 1e82eac..0000000 --- a/app/api/AuthRouterAPI.jsx +++ /dev/null @@ -1,30 +0,0 @@ -// - Import react components -import React, {Component} from 'react' -import {Route, Redirect} from 'react-router-dom' - -// - Import API -import * as AuthAPI from 'AuthAPI' - - -export let PrivateRoute = ({component: Component, ...rest}) => { - console.log('is auth ', AuthAPI.isAuthorized()) - return ( - AuthAPI.isAuthorized() - ? - : } - /> - ) -} - -export let PublicRoute = ({component: Component,...rest}) => { - return ( - !(AuthRouterAPI.isAuthorized()) - ? - : } - /> - ) -} diff --git a/app/components/Blog.jsx b/app/components/Blog.jsx index 69218cd..48d6e06 100644 --- a/app/components/Blog.jsx +++ b/app/components/Blog.jsx @@ -18,7 +18,6 @@ import PostWrite from 'PostWrite' import UserAvatar from 'UserAvatar' // - Import API -import * as AuthAPI from 'AuthAPI' import * as PostAPI from 'PostAPI' // - Import actions diff --git a/app/components/PostWrite.jsx b/app/components/PostWrite.jsx index ebf8967..4720e9e 100644 --- a/app/components/PostWrite.jsx +++ b/app/components/PostWrite.jsx @@ -24,7 +24,6 @@ import Img from 'Img' import UserAvatar from 'UserAvatar' // - Import API -import * as AuthAPI from 'AuthAPI' import * as PostAPI from 'PostAPI' // - Import actions diff --git a/app/components/Sidebar.jsx b/app/components/Sidebar.jsx index 415bafc..9b8e3e3 100644 --- a/app/components/Sidebar.jsx +++ b/app/components/Sidebar.jsx @@ -9,7 +9,6 @@ import keycode from 'keycode' // - Import API -import * as AuthAPI from 'AuthAPI' // - Import actions import * as authorizeActions from 'authorizeActions' diff --git a/app/helpers/index.jsx b/app/helpers/index.jsx deleted file mode 100644 index 2bf829e..0000000 --- a/app/helpers/index.jsx +++ /dev/null @@ -1,29 +0,0 @@ -import {firebaseAuth, firebaseRef} from 'app/firebase/' - -export function auth(email, pw, other) { - return firebaseAuth().createUserWithEmailAndPassword(email, pw) - .then(u => saveUser(u,other)) -} - -export function logout() { - return firebaseAuth().signOut() -} - -export function login(email, pw) { - return firebaseAuth().signInWithEmailAndPassword(email, pw) -} - -export function resetPassword(email) { - return firebaseAuth().sendPasswordResetEmail(email) -} - -export function saveUser(user,other) { - return firebaseRef.child(`users/${user.uid}/info`) - .set({ - ...other, - email: user.email, - uid: user.uid - - }) - .then(() => user) -}