backlink mistake in user-auth example, I think

caught-in-a-nette
Member | 6
+
0
-

Hi

I began my project using the User Authentication (Nette example) in Github.

I discovered that when I logged-in, the application never took me back to the last place – it always redirected me to the beginning. This was tested thoroughly for many days…

I tried in vain to do many related things (like saving the cookie in a different way), but I didn't really know what I was affecting…
Finally I just manually traced the steps. I came across the code in the “injectRequireLoggedUser” method within the “RequireLoggedUser” trait.
It didn't make sense to save the backlink:

['backlink' => $this->storeRequest()]

when the user had been logged-out ONLY. I decided to copy the same piece of code and put it in the login attempt section:
"
`php
if ($user->isLoggedIn()) {
return;
} elseif ($user->getLogoutReason() === $user::LogoutInactivity) {
$this->flashMessage(‘You have been signed out due to inactivity. Please sign in again.’);
$this->redirect(‘Login:’, [‘backlink’ ⇒ $this->storeRequest()]);
} else {
$this->redirect(‘Login:’, [‘backlink’ ⇒ $this->storeRequest()]);
 }

`":null
.

I believe this was a oversight and the above is how it should be. If not please explain why.

Infanticide0
Member | 82
+
0
-

Hi, do you call $this->restoreRequest($this->backlink); before redirecting after successful re-login?

caught-in-a-nette
Member | 6
+
0
-

Yes of course,

...
				$this->restoreRequest($this->backlink);
                $this->redirect('View:');
...