mirror of
https://github.com/Stremio/stremio-web.git
synced 2026-04-19 01:22:11 +00:00
22 lines
708 B
JavaScript
22 lines
708 B
JavaScript
// Copyright (C) 2017-2023 Smart code 203358507
|
|
|
|
const React = require('react');
|
|
const { Intro } = require('stremio/routes');
|
|
const { useProfile } = require('stremio/common');
|
|
|
|
const withProtectedRoutes = (Component) => {
|
|
return function withProtectedRoutes(props) {
|
|
const profile = useProfile();
|
|
const onRouteChange = React.useCallback((routeConfig) => {
|
|
if (profile.auth !== null && routeConfig.component === Intro) {
|
|
window.location.replace('#/');
|
|
return true;
|
|
}
|
|
}, [profile]);
|
|
return (
|
|
<Component {...props} onRouteChange={onRouteChange} />
|
|
);
|
|
}
|
|
};
|
|
|
|
module.exports = withProtectedRoutes;
|