title: Lumen Custom Authentication with custom Fields and Store in Auth Guard
body: <p>I am using lumen for API development. I have an issue in Lumen Custom Authentication. 
  I want to login a user when his credentials and account_name matches with stored record. In the credentials filed there is not username and password type data.</p>
  
  <p>here my login method</p>
  
  <pre><code>public function login(Request $request)
  {
  
      $this-&gt;validate($request,[
          'data.credentials' =&gt; 'required',
          'data.account_name' =&gt; 'required',
      ]);
  
      try {
          $credentials=$request-&gt;data['credentials'];
          $account_name=$request-&gt;data['account_name'];
          $user=User::where('account_name',$account_name)-&gt;where('credentials',$credentials)-&gt;first();
  
          if($user){
              // storing the authenticated user to the guard session
  
              $auth_token=Hash::make($account_name . ":" . $credentials);
  
              // update user auth token
              $user-&gt;auth_token=$auth_token;
              $user-&gt;update();
  
              $data="Some Data";
  
              return response()-&gt;json([
                  "auth_token"=&gt; $auth_token,
                  "data"=&gt;$data,
                  "request_id"=&gt; uniqid(),
                  "status"=&gt; "success"
              ]);
  
  
          }
  
      } catch (\Exception $e) {
          return response()-&gt;json(array(
              'error' =&gt; $e-&gt;getMessage(),
              'status' =&gt; 'failed',
              'status_code' =&gt; 500
          ));
      }
  
  }
  </code></pre>
  
  <p>I authenticated user with credentials I want to store that user in guard that can be default guard or custom and want to return auth_token from every response. if I use following code it give me an error.</p>
  
  <pre><code>Auth::guard()-&gt;attempt(['credentials'=&gt;$credentials,'account_name'=&gt;$account_name]);
  </code></pre>
  
  <p>It give an error that attempt_undefined_method. and If I use the following code</p>
  
  <pre><code>Auth::guard()-&gt;check(['credentials'=&gt;$credentials,'account_name'=&gt;$account]);
  </code></pre>
  
  <p>it returns the false value and do not store user in guard. I want such type of response from every request where I applied auth middleware</p>
  
  <pre><code>return response()-&gt;json([
          "auth_token"=&gt; auth()-&gt;user()-&gt;auth_token,
          "data"=&gt;$data,
          "request_id"=&gt; uniqid(),
          "status"=&gt; "success
  ]);
  </code></pre>
  
  <p>following is my AuthMiddleware.php code</p>
  
  <pre><code>$header=$request-&gt;header('Auth-Token');
  if(Auth::guard('api')){
          // we can use $user variable for further :)
          return $next($request);
    }
  </code></pre>