1

I made a modal for login at homepage and put {%requireLogin%} tag in "User Profile" page. My general.php file looks like below:

'dev' => [
        // Base site URL
        'siteUrl' => null,

        // Dev Mode (see https://craftcms.com/support/dev-mode)
        'devMode' => true,
        'loginPath' => '/',
    ],

I hope to prevent users to go to "User Profile" page without login and redirect them to homepage. But the issue is when I login on the homepage, the browser gives an error redirected you too many times.

Any idea how to do that please? Many thanks!!

1

OK, no one answered....I have to take another way to do which is to put a piece of code like this into user-profile page

{% if not currentUser %}
  {% redirect '/' %}
{% endif %}

and take out loginPath setting in config file.

  • Do you have a requireLogin tag on the homepage - the template behind the url you are routing to? What redirecting to the / does is redirect to the homepage. If you have a requireLogin tag on this page your routing will go haywire in an infinite loop. – Gįëł Tėttëłæår Mar 22 '18 at 21:01
  • @GįëłTėttëłæår no, it doesn't make any sense to make homepage login-required. And that's why I got confused. There's no requireLogin tag on homepage, why it keeps looping – yu xia Mar 23 '18 at 1:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.