This forum has moved to a new location and is in read-only mode. Please visit talk.octobercms.com to access the new location.

Audrey
Audrey

In the plugin rainlab.users documentation , it write to add this link:

<a data-request="onLogout" data-request-data="redirect: '/good-bye'">Sign out</a>

to our page for signing out. I do it. I have a session component on my default layout, which contains "login" to the property "redirect to" and "users" to the property "Allow only". Here is the code of "default.htm":

https://kopy.io/sOJWz

In my Home page, I added the Account component. "redirect to" is equal to "Home". Here is the code of "login.htm":

https://kopy.io/o9YvY

When I log in, it doesn't redirect to the home page but always to the last page in memory (redirect :: back). So, when I logged out, the Url will be "/good-bye". If I log in after logout, I'm redirecting to "/good-bye", but it's a nonexistent page.

I was wondering if it was normal for the plugin? If so, how can I change my code to always redirects to the home page when we logging in? If not, I don't see where I made a mistake.

Can you help me please?

Last updated

Parsec
Parsec

As far as I know, the redirect used in the component attributes you use in the layout or in the page setup is the URI where the user is redirected to if he/she is not logged in. You could add a data-request-data="redirect: '/home'" to your login button and see if that works

Audrey
Audrey

I don't know if I'm ok but it doesn't work My code: https://kopy.io/rOZm1

Audrey
Audrey

I found a half solution. I modified the logout link for that:

<a data-request="onLogout" data-request-data="redirect: '/home'">Sign out</a>

So, when I logged out and after I logged in, I'm redirect to "/home". However, the user can put a fake URL like: http://localhost/tomato/. Whatever the URL, the user is alway redirect to the login page. If he connect himself after the fake URL, he will be redirect to the last URL. He will see a not found page. I would prefer the redirect to the homepage.

1-4 of 4

You cannot edit posts or make replies: the forum has moved to talk.octobercms.com.