Remove unnecessary files for authorization
This commit is contained in:
@@ -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
|
||||
|
||||
}
|
||||
@@ -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='/' />}
|
||||
/>
|
||||
)
|
||||
}
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -9,7 +9,6 @@ import keycode from 'keycode'
|
||||
|
||||
|
||||
// - Import API
|
||||
import * as AuthAPI from 'AuthAPI'
|
||||
|
||||
// - Import actions
|
||||
import * as authorizeActions from 'authorizeActions'
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
Reference in New Issue
Block a user