0
私はアプリケーションを開発していますが、redux-auth-wrapperのリダイレクトに問題がありますが、私はドキュメントに従っていますが、常に例えばログイン後に自宅に行う「メートル:リダイレクト先のリダックス・オーダー・ラッパーの問題 - 常にホームにリダイレクト
は、私がアクセス:
http://localhost:3000/admin
私はにリダイレクトしています:
http://localhost:3000/login?redirect=%2Fadmin it's ritght!
でもログインした後、私は
にリダイレクトしていますhttp://localhost:3000/
ログイン後に/ adminに移動するにはどうすればよいですか?
マイバージョン:
"react-redux": "4.4.5",
"react-router": "3.2.0",
"react-router-redux": "4.0.6",
"redux": "3.6.0",
"redux-auth-wrapper": "2.0.2",
マイauth.js:
import locationHelperBuilder from 'redux-auth-wrapper/history3/locationHelper'
import { connectedRouterRedirect } from 'redux-auth-wrapper/history3/redirect'
import { routerActions } from 'react-router-redux'
import { Loading } from './components'
const locationHelper = locationHelperBuilder({})
export const userIsAuthenticated = connectedRouterRedirect({
redirectPath: '/login',
authenticatedSelector: state => state.auth.isAuthenticated,
authenticatingSelector: state => state.auth.isLoading,
AuthenticatingComponent: Loading,
redirectAction: routerActions.replace,
wrapperDisplayName: 'UserIsAuthenticated'
})
export const userIsAdmin = connectedRouterRedirect({
redirectPath: '/',
allowRedirectBack: false,
authenticatedSelector: state => state.auth.data !== null && state.auth.data.isAdmin,
redirectAction: routerActions.replace,
wrapperDisplayName: 'UserIsAdmin'
})
export const userIsNotAuthenticated = connectedRouterRedirect({
redirectPath: (state, ownProps) => locationHelper.getRedirectQueryParam(ownProps) || '/foo',
allowRedirectBack: false,
// Want to redirect the user when they are done loading and authenticated
authenticatedSelector: state => state.auth.data === null && state.auth.isLoading === false,
redirectAction: routerActions.replace,
wrapperDisplayName: 'UserIsNotAuthenticated'
})
マイroutes.js:
import React from 'react';
import { Route , IndexRoute } from 'react-router';
import App from './components/App';
import LoginPage from './containers/LoginPage';
import LogoutPage from './containers/LogoutPage';
import AdminPage from './containers/AdminPage';
import SelectSolution from './containers/SelectSolution';
import AboutPage from './components/AboutPage.js';
import NotFoundPage from './components/NotFoundPage.js';
import { userIsAuthenticated
// , userIsAdmin
// , userIsNotAuthenticated
} from './auth'
export default (
<Route path="/" component={App}>
<IndexRoute component={SelectSolution}/>
<Route path="login" component={LoginPage}/>
<Route path="logout" component={LogoutPage}/>
<Route path="admin" component={userIsAuthenticated(AdminPage)}/>
<Route path="about" component={AboutPage}/>
<Route path="*" component={NotFoundPage}/>
</Route>
);
誰かが私を助けることができますか?
申し訳ありませんが、私のログインコンポーネントは: – bugalaws