News:

Want to get involved in developing SMF, then why not lend a hand on our github!

Main Menu

Login redirects to boardindex

Started by Julius_2000, December 01, 2022, 10:09:30 AM

Previous topic - Next topic

Julius_2000

Hi everyone,

when I log in from inside a board or message, instead of going back to the topic or board it would redirect me to the boardindex.

Edit: I noticed that this happens first and foremost in the first board that I once added to the existing ones.
But it is also true for when I try to log in from inside any topic.

Any thoughts?

Sir Osis of Liver

Ashes and diamonds, foe and friend,
 we were all equal in the end.

                                     - R. Waters

Julius_2000

Hi @Sir Osis of Liver, thanks for your reply.

this is the list of mods we've got:

You cannot view this attachment.

I'm not sure it because of mods or whether it's due to my edits in the template files. Because I went back to an earlier version of my theme edit and there the login worked as expected. Now, I don't know if it's important to install each mod in each theme or if installing any mod takes effect in all themes you have installed..

Do you happen to know in which php file the login behavior is handled so I can have a look at my edits?

Sir Osis of Liver

Login is handled in LogInOut.php, but you shouldn't have messed with that if you were just editing theme templates.  Do you have same problem in Curve2?
Ashes and diamonds, foe and friend,
 we were all equal in the end.

                                     - R. Waters

Julius_2000

Hi,

what is Curve2?

I noticed that when I go back to the original theme (Pelikan Theme in our case) or an early version of my edit or to the SMF default theme, the login works as intented. So I believe that maybe one of my edits may cause this behavior.

Here's a list of the php files I use in my mod, which expanded from the original Peilikan Theme files as I needed to make some edits in other places.
You cannot view this attachment.

FYI, I uninstalled all mods, still no change in behavior.

Sir Osis of Liver

There are several redirects in Login.template.php that determine where user goes after logging in.  If you edited any of that code you may have broken something.  Look for "redirect".

Curve2 is 2.1 default theme.
Ashes and diamonds, foe and friend,
 we were all equal in the end.

                                     - R. Waters

Julius_2000

#6
Quote from: Sir Osis of Liver on December 02, 2022, 11:09:00 AMThere are several redirects in Login.template.php that determine where user goes after logging in.  If you edited any of that code you may have broken something.  Look for "redirect".

Curve2 is 2.1 default theme.


In Login.template I only changed the image for the maintenance mode.

There's another interesting observation I just made:
I just tried logging in from a topic, and as usual it brought me back to the boardindex. However, looking at the address bar, there's still the href link for the actual topic I was trying to log in from. When I press "refresh" in the browser (this time Edge, normally I use FF), the topic page gets displayed.  The same is true for when I do that from within boards.
Occassionally, I also get a suffix to the link something like ?PHPSESSID= and then a long line of letters and numbers.

Here's an example:
You cannot view this attachment.


In index.template I made the following edit pertaining to login:
echo '
<div id="main_menu" ';
/*changed: added for hiding menu if logged out*/
  if (!$context['user']['is_guest'])
echo '';
else
echo ' class="logged_out" ';

echo '>';
I needed to do that to get a class when logged out so that I could hide the secondary/redundant login/register buttons for guests via CSS.

Another edit I made is for my header that also involves login reference:
<div id="banner">
<span id="welcome">Welcome to the ChemBase';
if ($context['user']['is_logged'])
echo ', ', $context['user']['name'], '';

//First Logo svg placement for small mobiles
echo '!</span>

Could any of those changes have influenced this behavior?

Sir Osis of Liver

Save a backup of your Login.template.php, upload clean file, confirm that it works normally, then add your edits one at a time and see which one causes the problem.
Ashes and diamonds, foe and friend,
 we were all equal in the end.

                                     - R. Waters

Julius_2000

#8
Quote from: Sir Osis of Liver on December 02, 2022, 08:08:11 PMSave a backup of your Login.template.php, upload clean file, confirm that it works normally, then add your edits one at a time and see which one causes the problem.

Like I said, I only changed the "construction" image in Login.template.php for the maintenance mode. Nothing else.

<div class="information">
<img class="floatleft" src="', $settings['images_url'], '/Chems/construction.svg" width="280" height="140" alt="', $txt['in_maintain_mode'], '">
', $context['description'], '<br class="clear">

</div>


Ok, so I deleted those codes in the index.template.php, still nothing. I am still being redirected to the boardindex but the address bar shows the href for the correct board or topic I was in but doesn't load it apparently.

Edit
In a radical approach, I deleted all the files in my theme one by one and now it's empty and the SMF default files should apply. Still, no change in behavior. I'm at a loss.

There's a "core" folder in the "Themes" folder containting fairly old failes (2.0 or 2.0.16). Could they be the problem?

Julius_2000

Edit 2
I think I've nailed it down:

When I started editing our theme, I added the forum logo as an inline svg after the forumtitle code between the anchor in the index-template.php

<h1 class="forumtitle" title="the Chembase">
<a id="top" href="', $scripturl, '">', empty($context['header_logo_url_html_safe']) ? $context['forum_name_html_safe'] : '<img src="' . $context['header_logo_url_html_safe'] . '" alt="' . $context['forum_name_html_safe'] . '">
  <svg>[...]</svg>

I then would type in any text in the logo field in "Current Theme" and the svg logo would show up (I didn't know any better).

Now that I had reset everything and re-installed my theme, the logo was not yet there, only the forum name, as expected by the above code and it's if-condition. And voilá, I was able to log in from any board/ topic.

I've now replaced the if-condition after the anchor directly with the svg code and now everything works as intented (so far).
Is anyone able to explain why this happens?

Advertisement: