Skip to content

Commit

Permalink
fix: came_from loop
Browse files Browse the repository at this point in the history
  • Loading branch information
mamico committed Jul 12, 2024
1 parent 0b2d71d commit 3f20caa
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions src/components/ItaliaTheme/Header/HeaderSlim/LoginButton.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,20 @@ import { Button } from 'design-react-kit/dist/design-react-kit';
import config from '@plone/volto/registry';

const LoginButton = ({ children, size = 'full' }) => {
let [loginURL, setLoginURL] = useState(
const [loginURL, setLoginURL] = useState(
config.settings.siteProperties?.arLoginUrl,
);

useEffect(() => {
if (loginURL && __CLIENT__) {
if (loginURL.indexOf('came_from') < 0) {
let came_from = loginURL.indexOf('?') >= 0 ? '&' : '?';
came_from += 'came_from=' + window?.location?.href ?? '';
setLoginURL(loginURL + came_from);
const current = window?.location?.href;
if (
current &&
loginURL.indexOf('came_from') < 0 &&
current.indexOf('came_from') < 0
) {
const sep = loginURL.indexOf('?') >= 0 ? '&' : '?';
setLoginURL(`${loginURL}${sep}came_from=${current}`);
}
}
}, []);
Expand Down

0 comments on commit 3f20caa

Please sign in to comment.