Ich möchte eine Autorisierung in Meteor App mit react-Router v4 statt v3 aktualisieren.Refactor Authentifizierung mit react-Router 3 bis 4 in Meteor
Tracker.autorun(() => {
const isAuthenticated = !!Meteor.userId();
const pathname = browserHistory.getCurrentLocation().pathname;
const isUnauthenticatedPage = unauthenticatedPages.includes(pathname);
const isAuthenticatedPage = authenticatedPages.includes(pathname);
if (isUnauthenticatedPage && isAuthenticated) {
browserHistory.replace('/links');
} else if (isAuthenticatedPage && !isAuthenticated) {
browserHistory.replace('/');
}
});
Ich habe ein Beispiel aus der offiziellen Reaktiv-Router-Dokumentationsseite (https://reacttraining.com/react-router/web/example/auth-workflow) gesehen. Aber immer noch nicht wissen, es zu tun.