title: Is there any security issue to use this method of authenticating users in Laravel using the same login page?
body: <p>I'm a new Laravel Programmer and I tried to develop an web interface which uses the same login controller for two users which are from different tables. One user is Student and the other is Instructor. They are all routed to their intended page after login but I was wondering if there is any security issue to use this concept before I reach far? Or if there is any downside of using this logic or difficulties in implementing the logic or on trying securing the routes using middlewares?</p>
  <p><strong>Login Controller</strong></p>
  <pre><code> public function store(LoginRequest $request)
  {
      $credentials = $request-&gt;only('username', 'password');
  
  
      if(Auth::guard(&quot;instructor&quot;)-&gt;attempt($credentials))
      {
          return redirect()-&gt;route(&quot;instructor&quot;);
      }
  
      else if(Auth::guard(&quot;student&quot;)-&gt;attempt($credentials))
      {
          return redirect()-&gt;route(&quot;dashboard&quot;);
      }
  
      else
      {
          return back()-&gt;with('status', 'The provided credentials do not match our records.');
      }
  }
  </code></pre>
  <p><strong>Middlewares</strong></p>
  <pre><code>Route::middleware(&quot;auth:instructor&quot;)-&gt;group(function (){
  
  Route::get(&quot;/instructorDashboard&quot;, [DashboardController::class, &quot;instructor&quot;])-&gt;name(&quot;instructor&quot;);
  </code></pre>
  <p>});</p>
  <pre><code>  Route::middleware(&quot;auth:student&quot;)-&gt;group(function () {
  
  Route::get(&quot;/dashboard&quot;, [DashboardController::class, &quot;student&quot;])-&gt;name(&quot;dashboard&quot;);
  </code></pre>
  <p>});</p>
  <p><strong>Dashboard Controller (They just return normal text, not view)</strong></p>
  <pre><code>class DashboardController extends Controller
  </code></pre>
  <p>{</p>
  <pre><code>public function student (Request $request)
  {
      return &quot;Your a Student&quot;;
  }
  
  public function instructor(Request $request)
  {
      return &quot;Your a Instructor&quot;;
  }
  </code></pre>
  <p>}</p>
  <p><strong>auth.php file</strong></p>
  <pre><code> 'defaults' =&gt; [
      'guard' =&gt; 'student',
      'passwords' =&gt; 'users',
  ],
   'guards' =&gt; [
      'student' =&gt; [
          'driver' =&gt; 'session',
          'provider' =&gt; 'students',
      ],
  
      'instructor' =&gt; [
          'driver' =&gt; 'session',
          'provider' =&gt; 'instructors',
      ],
  
      'api' =&gt; [
          'driver' =&gt; 'token',
          'provider' =&gt; 'users',
          'hash' =&gt; false,
      ],
  
  
  ],
  'providers' =&gt; [
      'students' =&gt; [
          'driver' =&gt; 'eloquent',
          'model' =&gt; App\Models\Student::class,
      ],
      'instructors' =&gt; [
          'driver' =&gt; 'eloquent',
          'model' =&gt; App\Models\Instructor::class
      ],
      'users' =&gt; [
          'driver' =&gt; 'eloquent',
          'model' =&gt; App\Models\Student::class,
      ]
  ]
  </code></pre>