File tree Expand file tree Collapse file tree 3 files changed +53
-0
lines changed Expand file tree Collapse file tree 3 files changed +53
-0
lines changed Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ namespace App \Http \Controllers ;
4
+
5
+ class PortalController extends Controller
6
+ {
7
+ /**
8
+ * Show the application dashboard.
9
+ *
10
+ * @return \Illuminate\Http\Response
11
+ */
12
+ public function index ()
13
+ {
14
+ $ uri = session ('url ' ) ? session ('url ' ) : config ('wifidog.portal_redirect_uri ' );
15
+ return redirect ($ uri );
16
+ }
17
+ }
Original file line number Diff line number Diff line change 3
3
use App \Http \Controllers \DashboardController ;
4
4
use App \Http \Controllers \MessageController ;
5
5
use App \Http \Controllers \ProfileController ;
6
+ use App \Http \Controllers \PortalController ;
6
7
use App \Http \Controllers \Welcome ;
7
8
use Illuminate \Support \Facades \Route ;
8
9
20
21
require __DIR__ . '/auth.php ' ;
21
22
22
23
Route::get ('/messages ' , [MessageController::class, 'index ' ]);
24
+ Route::get ('/portal ' , [PortalController::class, 'index ' ])->middleware ('auth:sanctum ' );
Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ namespace Tests \Feature ;
4
+
5
+ use Tests \TestCase ;
6
+ use Illuminate \Foundation \Testing \RefreshDatabase ;
7
+ use App \Models \User ;
8
+
9
+ class PortalTest extends TestCase
10
+ {
11
+ use RefreshDatabase;
12
+
13
+ public function testIndex ()
14
+ {
15
+ $ user = User::factory ()->create ();
16
+ $ uri = fake ()->url ();
17
+ $ response = $ this ->actingAs ($ user )
18
+ ->withSession ([
19
+ 'url ' => $ uri ,
20
+ ])->get ('/portal/ ' );
21
+
22
+ $ response ->assertStatus (302 )->assertRedirect ($ uri );
23
+ }
24
+
25
+ public function testRedirectToConfigUri ()
26
+ {
27
+ $ user = User::factory ()->create ();
28
+ $ uri = fake ()->url ();
29
+ config (['wifidog.portal_redirect_uri ' => $ uri ]);
30
+ $ response = $ this ->actingAs ($ user )->get ('/portal/ ' );
31
+
32
+ $ response ->assertStatus (302 )->assertRedirect ($ uri );
33
+ }
34
+ }
You can’t perform that action at this time.
0 commit comments