How to check additional field during login in Laravel?











up vote
0
down vote

favorite
1












How to check additional field during login in Laravel?



Now it works from the box and accepts email and password. How to check additionally status parameter when user log in?



I use this LoginController:



use AppHttpControllersController;
use IlluminateFoundationAuthAuthenticatesUsers;

class LoginController extends Controller
{
use AuthenticatesUsers;
}


I tried this in LoginController:



public function authenticate(Request $request)
{
$credentials = $request->only('email', 'password');
$credentials['status'] = 1;

if (Auth::attempt($credentials)) {
return redirect()->intended('home');
}
}


But Laravel ignores this method authenticate().



if to remove use AuthenticatesUsers; it becomes alive, but then does not work logout, login page.










share|improve this question






















  • are you want to attach another parameter when user wants to login ? like email , password and user type ?
    – Emtiaz Zahid
    Nov 8 at 2:54










  • please check the right answer as your solution as stackoverflow policy. thanks
    – Emtiaz Zahid
    Nov 9 at 12:18















up vote
0
down vote

favorite
1












How to check additional field during login in Laravel?



Now it works from the box and accepts email and password. How to check additionally status parameter when user log in?



I use this LoginController:



use AppHttpControllersController;
use IlluminateFoundationAuthAuthenticatesUsers;

class LoginController extends Controller
{
use AuthenticatesUsers;
}


I tried this in LoginController:



public function authenticate(Request $request)
{
$credentials = $request->only('email', 'password');
$credentials['status'] = 1;

if (Auth::attempt($credentials)) {
return redirect()->intended('home');
}
}


But Laravel ignores this method authenticate().



if to remove use AuthenticatesUsers; it becomes alive, but then does not work logout, login page.










share|improve this question






















  • are you want to attach another parameter when user wants to login ? like email , password and user type ?
    – Emtiaz Zahid
    Nov 8 at 2:54










  • please check the right answer as your solution as stackoverflow policy. thanks
    – Emtiaz Zahid
    Nov 9 at 12:18













up vote
0
down vote

favorite
1









up vote
0
down vote

favorite
1






1





How to check additional field during login in Laravel?



Now it works from the box and accepts email and password. How to check additionally status parameter when user log in?



I use this LoginController:



use AppHttpControllersController;
use IlluminateFoundationAuthAuthenticatesUsers;

class LoginController extends Controller
{
use AuthenticatesUsers;
}


I tried this in LoginController:



public function authenticate(Request $request)
{
$credentials = $request->only('email', 'password');
$credentials['status'] = 1;

if (Auth::attempt($credentials)) {
return redirect()->intended('home');
}
}


But Laravel ignores this method authenticate().



if to remove use AuthenticatesUsers; it becomes alive, but then does not work logout, login page.










share|improve this question













How to check additional field during login in Laravel?



Now it works from the box and accepts email and password. How to check additionally status parameter when user log in?



I use this LoginController:



use AppHttpControllersController;
use IlluminateFoundationAuthAuthenticatesUsers;

class LoginController extends Controller
{
use AuthenticatesUsers;
}


I tried this in LoginController:



public function authenticate(Request $request)
{
$credentials = $request->only('email', 'password');
$credentials['status'] = 1;

if (Auth::attempt($credentials)) {
return redirect()->intended('home');
}
}


But Laravel ignores this method authenticate().



if to remove use AuthenticatesUsers; it becomes alive, but then does not work logout, login page.







laravel laravel-5 laravel-5.2






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 8 at 2:12









OPV

1,33621228




1,33621228












  • are you want to attach another parameter when user wants to login ? like email , password and user type ?
    – Emtiaz Zahid
    Nov 8 at 2:54










  • please check the right answer as your solution as stackoverflow policy. thanks
    – Emtiaz Zahid
    Nov 9 at 12:18


















  • are you want to attach another parameter when user wants to login ? like email , password and user type ?
    – Emtiaz Zahid
    Nov 8 at 2:54










  • please check the right answer as your solution as stackoverflow policy. thanks
    – Emtiaz Zahid
    Nov 9 at 12:18
















are you want to attach another parameter when user wants to login ? like email , password and user type ?
– Emtiaz Zahid
Nov 8 at 2:54




are you want to attach another parameter when user wants to login ? like email , password and user type ?
– Emtiaz Zahid
Nov 8 at 2:54












please check the right answer as your solution as stackoverflow policy. thanks
– Emtiaz Zahid
Nov 9 at 12:18




please check the right answer as your solution as stackoverflow policy. thanks
– Emtiaz Zahid
Nov 9 at 12:18












2 Answers
2






active

oldest

votes

















up vote
1
down vote



accepted










You can add another field to check login by credentials function



inside you LoginController add credentials function and append extra field with email, password



Example:



public function credentials(Request $request)
{
$credentials = $request->only($this->email(), 'password');
$credentials = array_add($credentials, 'status', '1');
return $credentials;
}





share|improve this answer




























    up vote
    1
    down vote













    Your question tag is laravel 5.2, then for 5.2 you should override getCredentials function:



    protected function getCredentials(Request $request)
    {
    $credentials = $request->only($this->loginUsername(), 'password');

    $credentials['status'] = 1;

    return $credentials;
    }




    if you using laravel 5.3+ the answer of Emtiaz Zahid is correct (override credentials function)






    share|improve this answer





















      Your Answer






      StackExchange.ifUsing("editor", function () {
      StackExchange.using("externalEditor", function () {
      StackExchange.using("snippets", function () {
      StackExchange.snippets.init();
      });
      });
      }, "code-snippets");

      StackExchange.ready(function() {
      var channelOptions = {
      tags: "".split(" "),
      id: "1"
      };
      initTagRenderer("".split(" "), "".split(" "), channelOptions);

      StackExchange.using("externalEditor", function() {
      // Have to fire editor after snippets, if snippets enabled
      if (StackExchange.settings.snippets.snippetsEnabled) {
      StackExchange.using("snippets", function() {
      createEditor();
      });
      }
      else {
      createEditor();
      }
      });

      function createEditor() {
      StackExchange.prepareEditor({
      heartbeatType: 'answer',
      convertImagesToLinks: true,
      noModals: true,
      showLowRepImageUploadWarning: true,
      reputationToPostImages: 10,
      bindNavPrevention: true,
      postfix: "",
      imageUploader: {
      brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
      contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
      allowUrls: true
      },
      onDemand: true,
      discardSelector: ".discard-answer"
      ,immediatelyShowMarkdownHelp:true
      });


      }
      });














      draft saved

      draft discarded


















      StackExchange.ready(
      function () {
      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53200586%2fhow-to-check-additional-field-during-login-in-laravel%23new-answer', 'question_page');
      }
      );

      Post as a guest















      Required, but never shown

























      2 Answers
      2






      active

      oldest

      votes








      2 Answers
      2






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes








      up vote
      1
      down vote



      accepted










      You can add another field to check login by credentials function



      inside you LoginController add credentials function and append extra field with email, password



      Example:



      public function credentials(Request $request)
      {
      $credentials = $request->only($this->email(), 'password');
      $credentials = array_add($credentials, 'status', '1');
      return $credentials;
      }





      share|improve this answer

























        up vote
        1
        down vote



        accepted










        You can add another field to check login by credentials function



        inside you LoginController add credentials function and append extra field with email, password



        Example:



        public function credentials(Request $request)
        {
        $credentials = $request->only($this->email(), 'password');
        $credentials = array_add($credentials, 'status', '1');
        return $credentials;
        }





        share|improve this answer























          up vote
          1
          down vote



          accepted







          up vote
          1
          down vote



          accepted






          You can add another field to check login by credentials function



          inside you LoginController add credentials function and append extra field with email, password



          Example:



          public function credentials(Request $request)
          {
          $credentials = $request->only($this->email(), 'password');
          $credentials = array_add($credentials, 'status', '1');
          return $credentials;
          }





          share|improve this answer












          You can add another field to check login by credentials function



          inside you LoginController add credentials function and append extra field with email, password



          Example:



          public function credentials(Request $request)
          {
          $credentials = $request->only($this->email(), 'password');
          $credentials = array_add($credentials, 'status', '1');
          return $credentials;
          }






          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Nov 8 at 2:59









          Emtiaz Zahid

          1,015516




          1,015516
























              up vote
              1
              down vote













              Your question tag is laravel 5.2, then for 5.2 you should override getCredentials function:



              protected function getCredentials(Request $request)
              {
              $credentials = $request->only($this->loginUsername(), 'password');

              $credentials['status'] = 1;

              return $credentials;
              }




              if you using laravel 5.3+ the answer of Emtiaz Zahid is correct (override credentials function)






              share|improve this answer

























                up vote
                1
                down vote













                Your question tag is laravel 5.2, then for 5.2 you should override getCredentials function:



                protected function getCredentials(Request $request)
                {
                $credentials = $request->only($this->loginUsername(), 'password');

                $credentials['status'] = 1;

                return $credentials;
                }




                if you using laravel 5.3+ the answer of Emtiaz Zahid is correct (override credentials function)






                share|improve this answer























                  up vote
                  1
                  down vote










                  up vote
                  1
                  down vote









                  Your question tag is laravel 5.2, then for 5.2 you should override getCredentials function:



                  protected function getCredentials(Request $request)
                  {
                  $credentials = $request->only($this->loginUsername(), 'password');

                  $credentials['status'] = 1;

                  return $credentials;
                  }




                  if you using laravel 5.3+ the answer of Emtiaz Zahid is correct (override credentials function)






                  share|improve this answer












                  Your question tag is laravel 5.2, then for 5.2 you should override getCredentials function:



                  protected function getCredentials(Request $request)
                  {
                  $credentials = $request->only($this->loginUsername(), 'password');

                  $credentials['status'] = 1;

                  return $credentials;
                  }




                  if you using laravel 5.3+ the answer of Emtiaz Zahid is correct (override credentials function)







                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered Nov 8 at 3:31









                  Erick Patrick

                  30124




                  30124






























                      draft saved

                      draft discarded




















































                      Thanks for contributing an answer to Stack Overflow!


                      • Please be sure to answer the question. Provide details and share your research!

                      But avoid



                      • Asking for help, clarification, or responding to other answers.

                      • Making statements based on opinion; back them up with references or personal experience.


                      To learn more, see our tips on writing great answers.





                      Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


                      Please pay close attention to the following guidance:


                      • Please be sure to answer the question. Provide details and share your research!

                      But avoid



                      • Asking for help, clarification, or responding to other answers.

                      • Making statements based on opinion; back them up with references or personal experience.


                      To learn more, see our tips on writing great answers.




                      draft saved


                      draft discarded














                      StackExchange.ready(
                      function () {
                      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53200586%2fhow-to-check-additional-field-during-login-in-laravel%23new-answer', 'question_page');
                      }
                      );

                      Post as a guest















                      Required, but never shown





















































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown

































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown







                      這個網誌中的熱門文章

                      Tangent Lines Diagram Along Smooth Curve

                      Yusuf al-Mu'taman ibn Hud

                      Zucchini