Remove unnecessary files for authorization

This commit is contained in:
Qolzam
2017-10-21 11:08:41 +07:00
parent 736023709b
commit df84c80899
6 changed files with 0 additions and 78 deletions

View File

@@ -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
}

View File

@@ -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 (
<Route
{...rest}
render={(props) => AuthAPI.isAuthorized()
? <Component {...props} />
: <Redirect to={{pathname: '/login', state: {from: props.location}}} />}
/>
)
}
export let PublicRoute = ({component: Component,...rest}) => {
return (
<Route
{...rest}
render={(props) => !(AuthRouterAPI.isAuthorized())
? <Component {...props} />
: <Redirect to='/' />}
/>
)
}

View File

@@ -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

View File

@@ -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

View File

@@ -9,7 +9,6 @@ import keycode from 'keycode'
// - Import API
import * as AuthAPI from 'AuthAPI'
// - Import actions
import * as authorizeActions from 'authorizeActions'

View File

@@ -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)
}