Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F117740955
D1768.1775162020.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Authored By
Unknown
Size
2 KB
Referenced Files
None
Subscribers
None
D1768.1775162020.diff
View Options
diff --git a/src/resources/js/app.js b/src/resources/js/app.js
--- a/src/resources/js/app.js
+++ b/src/resources/js/app.js
@@ -143,6 +143,11 @@
if (!error.response) {
// TODO: probably network connection error
} else if (error.response.status === 401) {
+ // Remember requested route to come back to it after log in
+ if (this.$route.meta.requiresAuth) {
+ store.state.afterLogin = this.$route
+ }
+
this.logoutUser()
} else {
this.errorPage(error.response.status, error.response.statusText)
diff --git a/src/tests/Browser/LogonTest.php b/src/tests/Browser/LogonTest.php
--- a/src/tests/Browser/LogonTest.php
+++ b/src/tests/Browser/LogonTest.php
@@ -7,6 +7,7 @@
use Tests\Browser\Components\Toast;
use Tests\Browser\Pages\Dashboard;
use Tests\Browser\Pages\Home;
+use Tests\Browser\Pages\UserProfile;
use Tests\TestCaseDusk;
use Illuminate\Foundation\Testing\DatabaseMigrations;
@@ -37,7 +38,7 @@
/**
* Test redirect to /login if user is unauthenticated
*/
- public function testLogonRedirect(): void
+ public function testRequiredAuth(): void
{
$this->browse(function (Browser $browser) {
$browser->visit('/dashboard');
@@ -208,4 +209,24 @@
->on(new Dashboard());
});
}
+
+ /**
+ * Test redirect to the requested page after logon
+ *
+ * @depends test2FA
+ */
+ public function testAfterLogonRedirect(): void
+ {
+ $this->browse(function (Browser $browser) {
+ // User is logged in
+ $browser->visit(new UserProfile());
+
+ // Test redirect if the token is invalid
+ $browser->script("localStorage.setItem('token', '123')");
+ $browser->refresh()
+ ->on(new Home())
+ ->submitLogon('john@kolab.org', 'simple123', false)
+ ->waitForLocation('/profile');
+ });
+ }
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Thu, Apr 2, 8:33 PM (5 h, 22 m ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
18820732
Default Alt Text
D1768.1775162020.diff (2 KB)
Attached To
Mode
D1768: Fix logon redirect when the token exists, but is invalid/expired
Attached
Detach File
Event Timeline