Configuring Multi Auth Middleware - Native Laravel 5.4 Multiple Authentication Series (Part 3)

แชร์
ฝัง
  • เผยแพร่เมื่อ 9 พ.ย. 2024

ความคิดเห็น • 332

  • @saudqureshi3716
    @saudqureshi3716 6 ปีที่แล้ว +18

    I learned laravel in september 2017 I learned it from your channel following your how to make a blog with laravel 5.4, It's october 2018 and I have a job (developer in an organisation) It all happened because of you Alex, I thank you for helping the guys like me out in being a laravel developer, You helped me change my life and get a job, you are actually changing lives sir, Thank you so much for this

  • @djwave28
    @djwave28 6 ปีที่แล้ว

    This is a great tut. To solve newer versions (5.6 tested) with missing "function unauthenticated" in the "Handler", just create the function. Works fine!

  • @ronaldlatina1622
    @ronaldlatina1622 4 ปีที่แล้ว

    Thank You so much.. I using laravel 7x, and i also thanks for others who commenting suggestions for updated laravel.. Appreciated :)

  • @plo1T-
    @plo1T- 7 ปีที่แล้ว

    Awesome guide. In the RedirectIfAuthenticated middleware, I actually did the IF statement first, then the SWITCH statement inside the IF. Thanks, this is what I needed.

  • @pranavkulkarni3684
    @pranavkulkarni3684 7 ปีที่แล้ว +45

    Awesome tutorial and very well explained as usual.
    I have a request for a you. Can you please make a series on User Role/Authorization app in Laravel? that would be really helpful.

  • @soultouchingsongs
    @soultouchingsongs 7 ปีที่แล้ว

    The best tutorial on laravel multi-authentication. Previously I relied on Sentinel package for this. But, as you said, had problems when migration to the next laravel version.Thanks a million!

  • @eduardocintra8540
    @eduardocintra8540 6 ปีที่แล้ว +10

    I saw that some people are trying to use this with new laravel version (5.5 and 5.6) without success, I got it doing this:
    1 - Add to header of "Handler.php" the following:
    use Illuminate\Auth\AuthenticationException;
    2 - At the end of file, add the following method:
    protected function unauthenticated($request, AuthenticationException $exception)
    {
    if($request->expectsJson()){
    return response()->json(['message' => $exception->getMessage()], 401);
    }

    $guard = array_get($exception->guards(), 0);
    switch ($guard){
    case 'admin':
    $login = 'admin.login';
    break;
    default:
    $login = 'login';
    break;
    }
    return redirect()->guest(route($login));
    }
    It's working for me.

    • @Short_Storm
      @Short_Storm 6 ปีที่แล้ว

      thanks alot mate for your comment. it definetly helped alot, but still i can get to user login view while admin is already logged in, which allow my user to get logged in as well, thus i can have both admin and user logged in at same time. Do you have any idea why is this happening!

    • @Slav0v
      @Slav0v 6 ปีที่แล้ว

      I thought about first point, but you save me in the second - in the if statement. Thank you my man!

    • @brayancabrera6036
      @brayancabrera6036 6 ปีที่แล้ว

      el papu de los papus gracias men

    • @SharkBait_ZA
      @SharkBait_ZA 6 ปีที่แล้ว

      I am on Laravel 5.7 and can't get this to work. If I dd($exception), I get the following:
      AuthenticationException {#499 ▼
      #guards: array:1 [▼
      0 => null
      ]
      #redirectTo: "127.0.0.1:8000/login"
      #message: "Unauthenticated."
      #code: 0
      #file: "C:\Users\Spare\OneDrive\Werner\Sites\multiauth\vendor\laravel\framework\src\Illuminate\Auth\Middleware\Authenticate.php"
      #line: 67
      trace: {▶}
      }
      I am logged in with my admin user. I have tried restarting the server, but no success.

    • @magicorpse
      @magicorpse 5 ปีที่แล้ว

      Obrigado senhor Eduardo Cintra.

  • @FarhanKhan-cp2kw
    @FarhanKhan-cp2kw 5 ปีที่แล้ว

    Great, this is just awesome! Great Tutorials...... clear and complete explanation for most of the things. Just a quick suggestion for viewers who are using laravel 6.0 (as well as me) is that you may face problems with handler.php. No worries, just follow stackoverflow instantly to solve and understand them

    • @ainanahmed2517
      @ainanahmed2517 5 ปีที่แล้ว

      Can you tell me the solution?

    • @FarhanKhan-cp2kw
      @FarhanKhan-cp2kw 5 ปีที่แล้ว

      sure, tell me where you are facing the problem

    • @ainanahmed2517
      @ainanahmed2517 5 ปีที่แล้ว

      @@FarhanKhan-cp2kw I'm having problem with redirecting the unauthenticated users. . . Can you give me the code for that? I'm using laravel 6.

  • @richardkolen9111
    @richardkolen9111 7 ปีที่แล้ว

    Nice! Learning great stuff from you as a Laravel noob. You make the best Laravel tutorials, great explanations. Can't wait for the advanced cms series to come out.

  • @adnanjam
    @adnanjam 7 ปีที่แล้ว

    It seems like you're a real teacher, like professionally

  • @scicommerce
    @scicommerce 7 ปีที่แล้ว +2

    Hey Man, thank you so much to put these together. Clear and nice tutorial! (Crazy to see some commenter just complaining.)

  • @jacklindcosta6740
    @jacklindcosta6740 3 ปีที่แล้ว

    Excellent! little changes needed in laravel 6 , described below.

  • @ankitvishwakarma1435
    @ankitvishwakarma1435 7 ปีที่แล้ว

    I loved the way every thing has been instructed. Just followed step by step and I am done. Thanks

  • @Ic3Arena
    @Ic3Arena 6 ปีที่แล้ว +5

    For anyone doing this tutorial in Laravel 5.5 or newer, you'll need to pull the exception from the framework into your project's exception hander as explained here:
    stackoverflow.com/questions/45340855/laravel-5-5-change-unauthenticated-login-redirect-url
    Great tutorial Alex, love your work mate. :-)

    • @shehan.akalanka
      @shehan.akalanka 3 ปีที่แล้ว

      Thank you very much! You're a good person

  • @YasirAli91
    @YasirAli91 4 ปีที่แล้ว +1

    For Laravel 6+ and if you only have 2 type of users you can use the following:
    public function render($request, Exception $exception)
    {
    if($exception instanceof AuthenticationException){
    $guard = Arr::get($exception->guards(), 0);
    return redirect(route( ($guard == 'seller')?'seller.login':'login' ));
    }
    return parent::render($request, $exception);
    }
    include this in the top:
    use Illuminate\Auth\AuthenticationException;
    use Illuminate\Support\Arr;

  • @dominiquetheodore3179
    @dominiquetheodore3179 7 ปีที่แล้ว

    Awesome tutorial!! Learnt a lot really. Btw the link for Part 1 and 2 are the same in the description. Thank you for sharing your knowledge with us!

  • @henrymbuguakiarie
    @henrymbuguakiarie 7 ปีที่แล้ว +11

    Awesome tutorial, waiting for part 4.

  • @recuperocreditilubex3663
    @recuperocreditilubex3663 7 ปีที่แล้ว

    Great tutorials Alex, thank you very much!!
    Did you notice that:
    - if you login as user in multiauth.dev/admin/login you don't get "These credentials do not match our records."
    - if you login as admin in multiauth.dev/login you correctly get "These credentials do not match our records."

    • @samirhrnjic3987
      @samirhrnjic3987 7 ปีที่แล้ว

      U can use session object to display
      session()->flash('message', 'These credentials do not match our records.');
      then in blade template check if session exists
      @if($flash = session('message'))
      {{ $flash }}
      @endif

  • @regisfernandojb
    @regisfernandojb 7 ปีที่แล้ว

    That was pretty confusing at the beginning, but you made it clear! Thank you very much and congrats for the amazing tutorial!

  • @--INDIAN--TRADER
    @--INDIAN--TRADER 7 ปีที่แล้ว +1

    still waiting for the final slice of multi auth ... grt work bytheway ...loved it and enjoyed a ton

  • @عبدالرزاقالخيشني
    @عبدالرزاقالخيشني 7 ปีที่แล้ว

    I owe a lot for you , I am eagerly waiting for what coming ... thanks ton .

  • @joecolas
    @joecolas 5 ปีที่แล้ว +1

    thank you so much Alexander . you saved me. I wish you all the best

  • @androidbot313
    @androidbot313 7 ปีที่แล้ว

    You are amazing man, you remind me of jeffrey way. You two are my favorite laravel teachers

  • @SyaifulMaulanaAbbidin
    @SyaifulMaulanaAbbidin 4 ปีที่แล้ว

    For Laravel 6. + , you can do a little bit of change:
    use Illuminate\Auth\AuthenticationException;
    use Illuminate\Support\Arr;
    public function render($request, Exception $exception)
    {
    if($exception instanceof AuthenticationException){
    $guard = Arr::get($exception->guards(), 0);
    switch($guard){
    case 'admin':
    return redirect(route('admin.login'));
    break;
    default:
    return redirect(route('login'));
    break;
    }
    }
    return parent::render($request, $exception);
    }

  • @shreyanshududhane4153
    @shreyanshududhane4153 3 ปีที่แล้ว +1

    Great tutorials!
    Laravel 8 does not writes this "unauthenticated" function for us, but we can add it ourselves, works!
    This is my Handler.php file

  • @prashantsilpakar7109
    @prashantsilpakar7109 5 ปีที่แล้ว

    best tutorial for laravel multi authentication !!! cheers!!!

  • @vincej151
    @vincej151 7 ปีที่แล้ว +1

    Great tutorial! However, there is one major problem: when you logout of Admin, L5 sends you to the hard coded default of "/" which will refer to the users login, not the Admin login. This is going to be hugely confusing for Admins who log out, then wish to log back in, and the system will advise them that their username / password is incorrect.
    Ideally, you need to have a single login page under "/" for both users and Admins, and so in this way it will not matter if L5 sends you back to that. I think this could be achievable if when an admin / user logs in, you check the users DB table where you have a column denoting if they are an Admin or user. If the user is an Admin, then you will be sent via the admin guard to the Admin login controller. This way you will still have admin and user guards protecting their own pages, and a single login page.

  • @sosyda4419
    @sosyda4419 6 ปีที่แล้ว

    finally after searching and trying a lot of solution I found this amazing tutorial I would like to make 1000 like on this video thank you

  • @joinerleal
    @joinerleal 7 ปีที่แล้ว

    Hey man, I really appreciate what you did here, it helped me a lot, thank you.

  • @md.mahadyhasan8456
    @md.mahadyhasan8456 7 ปีที่แล้ว +1

    Excellent tutorial !! just waiting for Part-4.

  • @TheKrauszer
    @TheKrauszer 7 ปีที่แล้ว

    Thank you so much for your videos, I really feel like I'm learning and not just guessing whats going on without an explication. greetings from Chile ;D

  • @DaveSohan
    @DaveSohan 7 ปีที่แล้ว +5

    Waiting for the updated version of this :)

  • @doms05
    @doms05 6 ปีที่แล้ว

    Awesome very straightforward. Thanks!

  • @adevjitgulati1137
    @adevjitgulati1137 7 ปีที่แล้ว +1

    Hey man, great tutorial. I had a question regarding the nav blade for admin. There is a line where it shows the logged in user Auth::user()->email. I am confused as to how to use admin()->email.. am I missing something?

  • @jeroenverloop982
    @jeroenverloop982 7 ปีที่แล้ว

    Hi Alex,
    Thnx for the awesome vids! I really like how you explain things thoroughly and clear.
    I wanted to ask you when you are planning to add the last video in this series? I really want to learn about the 'Forgot your password' part.

  • @JenniferJames-gj4ol
    @JenniferJames-gj4ol 5 ปีที่แล้ว +1

    Awesome... very well xplained.. show u working demo soon on 5.8

  • @arijithajra62
    @arijithajra62 7 ปีที่แล้ว

    Just one word for you "Awesome" ..... Keep it up man :)

  • @ivan.sammartino
    @ivan.sammartino 6 ปีที่แล้ว

    This tutorial is simply GREAT! :-)
    Just a couple of things, please...
    1. In the RedirectifAuthenticated middleware, can I replace your code with this? (the "switch" is inside the "if" so I don't repeat the "if (Auth::guard($guard)->check())" part)
    if (Auth::guard($guard)->check()) {
    switch ($guard) {
    case 'admin':
    return redirect(route('admin.dashboard'));
    break;
    default:
    return redirect(route('home'));
    }
    }
    seems that it work, but is there any side effect?
    2. Can I "oversimplify" all with the following code? And again, are there some side effects?
    if (Auth::guard($guard)->check()) {
    return redirect()->back();
    }
    In this way I'm always redirected to the previous page, that I know for sure it works (because I'm coming from there)
    Thanks a lot, again :-)

  • @--INDIAN--TRADER
    @--INDIAN--TRADER 7 ปีที่แล้ว

    gr8 thanks a tons loves it love it.. nicely explained thanks a ton keep up the goooood work alex

  • @joleolp
    @joleolp 7 ปีที่แล้ว +3

    Hello Alex, a question how can I make admins and users login in a single login both on different models?

  • @winex01
    @winex01 7 ปีที่แล้ว +14

    for those newbie or beginner like me that tried this on laravel 5.5.
    to make it work try to see this link below
    stackoverflow.com/questions/45340855/laravel-5-5-change-unauthenticated-login-redirect-url

    • @pitayapj
      @pitayapj 7 ปีที่แล้ว

      thank you, my friend :D

    • @OctoCoreHU
      @OctoCoreHU 7 ปีที่แล้ว

      Ahh i've just spent 1 hour instead of scrolling down :D THX

    • @DaveSohan
      @DaveSohan 7 ปีที่แล้ว

      But how do you write the switch case in this?

    • @pitayapj
      @pitayapj 7 ปีที่แล้ว

      what switch case ? switch case for what dude ? please have specific example

    • @nadyjess
      @nadyjess 7 ปีที่แล้ว

      Thanks!!! Your comment really helped me

  • @hledaczvirat_cz
    @hledaczvirat_cz 5 ปีที่แล้ว +5

    if you want to acces array helpers you need to run : composer require laravel/helpers
    then you can use array_get()

    • @5Gamingx
      @5Gamingx 5 ปีที่แล้ว

      great

    • @GursewakSingh-gx6ev
      @GursewakSingh-gx6ev 4 ปีที่แล้ว

      in latest version array_get() is deprecated use Arr::get()

    • @norbertseho
      @norbertseho 4 ปีที่แล้ว

      @@GursewakSingh-gx6ev i have a problem.. in laravel 7 i cant find exception handler but authenticate middleware is present and the function doing returning the user to the respective page only takes the request and i cant find how to pull guard from the request... im not sure if it even exists

    • @GursewakSingh-gx6ev
      @GursewakSingh-gx6ev 4 ปีที่แล้ว

      @@norbertseho Oh okay I understand your problem, so much have changed since this video was uploaded. Drop me a message on linkedIn we will discuss it over there. www.linkedin.com/in/gursewak-singh-ai-2019/

  • @ariefbudiprasetyo1440
    @ariefbudiprasetyo1440 7 ปีที่แล้ว

    wow,, awesome tutorial as usual,,
    seems you have huge knowledge in laravel

  • @GursewakSingh-gx6ev
    @GursewakSingh-gx6ev 4 ปีที่แล้ว

    I really loves your laravel series it helps me a lot, could you come up with series explaining untouched part of laravel like containers, event, listeners, providers, gates with a project?

  • @kangdaniel1890
    @kangdaniel1890 7 ปีที่แล้ว +1

    Great Tutorial!! THANK YOU SO MUCH From INDONESIA~

  • @hamidvetr
    @hamidvetr 7 ปีที่แล้ว

    great job Alex. still waiting for the fourth video in this series

  • @iglik3527
    @iglik3527 5 ปีที่แล้ว +3

    For Laravel 6 go to app/Exeptions/Handler.php
    ================================================
    public function render($request, Exception $exception)
    {
    if($exception instanceof AuthenticationException){
    $guard = Arr::get($exception->guards(), 0);
    switch($guard){
    case 'admin':
    return redirect(route('admin.login'));
    break;
    default:
    return redirect(route('login'));
    break;
    }
    }
    return parent::render($request, $exception);
    }
    }
    =================================================
    Also dont forget to include at the top of the page:
    use Arr;
    use Illuminate\Auth\AuthenticationException;

  • @ariel5515
    @ariel5515 5 ปีที่แล้ว

    Cool video but honestly a prefer to manage this case as a role case and manage everything as users permissions roles to give acces and view different ui with something like spattie permissions package its well tested and its code works with guards as your code does so it guarantee compatibilty and not remake the wheel but thanks this series is very educational thanks

  • @naelsaeed1351
    @naelsaeed1351 7 ปีที่แล้ว

    Hello Alex,
    First of all I would like to thank you for all the effort you are doing with all the lessons.
    I want to ask you a favour if you may please. Could you make video lessons about making an ACL or Role Auth System? Like when you want to create a website where Admins have multi types as you said.
    Thanks :)

  • @johncarloadvincula6022
    @johncarloadvincula6022 6 ปีที่แล้ว

    this tutorial is great. I would like to ask if there is a logout for both admin and casual users? for example if the admin and casual user are both logged in, if the admin click the logout, is casual user still logged in? Thank you so much for this tutorial
    +

  • @vigneshwaran4764
    @vigneshwaran4764 7 ปีที่แล้ว +1

    Great tutorial bro. Waiting for your next one.

  • @MrAKGarg007
    @MrAKGarg007 6 ปีที่แล้ว

    You can do like this in 5.5 or above .
    Just include these three lines below namespace
    use Request;
    use Illuminate\Auth\AuthenticationException;
    use Response;
    After that, Upgrade this function
    public function render($request, Exception $exception)
    {
    $class = get_class($exception);
    switch($class) {
    case 'Illuminate\Auth\AuthenticationException':
    $guard = array_get($exception->guards(), 0);
    switch ($guard) {
    case 'admin':
    $login = 'admin.login';
    break;
    default:
    $login = 'login';
    break;
    }
    return redirect()->route($login);
    }
    return parent::render($request, $exception);
    }

  • @blessed-favored
    @blessed-favored 6 ปีที่แล้ว

    Thank you. Awesome tutorial.

  • @tmbrwn_
    @tmbrwn_ 6 ปีที่แล้ว

    Shorthand versions., this works for me in 5.5:
    For the auth middleware...
    $login = (array_get($exception->guards(), 0) == 'admin') ? 'admin.login' : 'login';
    return redirect()->guest(route($login));
    For the guest middleware...
    $home = ($guard == 'admin') ? 'admin.dashboard' : 'home';
    return redirect(route($home));

  • @BajoQTI
    @BajoQTI 7 ปีที่แล้ว

    In truth it is an excellent tutorial and you are a very good teacher, you helped me a lot. Thank you very much ... if possible I would like you to make a notifications tutorial in laravel

  • @bejaouicyrine9050
    @bejaouicyrine9050 7 ปีที่แล้ว +4

    hello Alex
    can you post a video that show us how we manage the users authentification when he forget his password with the server SMTP ?

  • @sananjan
    @sananjan 6 ปีที่แล้ว +1

    When I use all things which you provide in this video all i change but when i going to login in error come in verifyCsrfToken.php (trying to get property 'headers' of non-object; in laravel 5.5 /admin/login

  • @portesbruno
    @portesbruno 7 ปีที่แล้ว

    Its work. Awesome tutorial

  • @davidbnpl
    @davidbnpl 7 ปีที่แล้ว

    11:00 - it's possible that guard array is empty.
    14:00 - it's possible that $guars is null.
    Both scenarios happened to me if the guard was default. It wasn't "web" but null. Your code is working because you use "default" in switch statement. It could stop working if you did "case 'web':" instead.

  • @amitpri1
    @amitpri1 7 ปีที่แล้ว +3

    Laravel 5.5 Exceptional Handler is very much different than this one. Please suggest where to make these changes

    • @saudqureshi3716
      @saudqureshi3716 6 ปีที่แล้ว

      just write the whole unauthenticated method in Handler.php. that's what "overriding" is

  • @patrickmcvey937
    @patrickmcvey937 6 ปีที่แล้ว

    Awesome tutorial, thanks!

  • @max82fr
    @max82fr 7 ปีที่แล้ว

    Hi Alex,
    Lots of people are waiting for part 4 here. Any idea when?

  • @max82fr
    @max82fr 7 ปีที่แล้ว +2

    Hi Alex,
    Any news on this please >> "Part 4: Forgot My Password Functionality across Multiple User Types
    Coming Soon."

  • @gimhanikanchana6630
    @gimhanikanchana6630 4 ปีที่แล้ว

    Thank you Very very much sir!!!!!!

  • @moycs777
    @moycs777 7 ปีที่แล้ว

    hi, thanks so much for this series :D

  • @yiroyi2894
    @yiroyi2894 7 ปีที่แล้ว +1

    Nice video , waiting for Part # 4 :)

  • @MozahidRanaRasel
    @MozahidRanaRasel 7 ปีที่แล้ว

    Thank you for this tutorial, really this video is very helpful :)

  • @itone3438
    @itone3438 2 ปีที่แล้ว

    thanks for this serie

  • @sazzadhussain
    @sazzadhussain 7 ปีที่แล้ว +4

    In Laravel 5.5 Handler.php has been changed. So how can we implement this functionality?
    Do I need to change in RedirectIfAuthenticated Class ? check in handle function and redirect accordingly ?.

    • @JacurtisTutorials
      @JacurtisTutorials  7 ปีที่แล้ว +6

      Going to be working on an updated video of this soon. I have been busy with other projects, but I am coming back to update it to 5.5 with the new handler methods.

    • @sazzadhussain
      @sazzadhussain 7 ปีที่แล้ว

      DevMarketer Thank u. Waiting for the updated video

    • @Maruf-zt7dz
      @Maruf-zt7dz 7 ปีที่แล้ว

      Please do this

    • @ikikika
      @ikikika 7 ปีที่แล้ว

      stackoverflow.com/a/45994994 hi, i tried this workaround on stackoverflow and it worked for me. perhaps you can try it as well until Alex post the L5.5 update for this video. Cheers.

    • @BaRzOmk
      @BaRzOmk 6 ปีที่แล้ว +2

      Do this changes in App\Exceptions\Handler.php...
      use Illuminate\Auth\AuthenticationException;
      /**
      * Convert an authentication exception into a response.
      *
      * @param \Illuminate\Http\Request $request
      * @param \Illuminate\Auth\AuthenticationException $exception
      * @return \Illuminate\Http\Response
      */
      protected function unauthenticated($request, AuthenticationException $exception)
      {
      if ($request->expectsJson()) {
      return response()->json(['error' => 'Unauthenticated.'], 401);
      }
      $guard = array_get($exception->guards(), 0);
      if ($guard === 'admin') {
      return redirect()->guest(route('admin.login'));
      }
      return redirect()->guest(route('login'));
      }

  • @DenniS-qr3nn
    @DenniS-qr3nn 7 ปีที่แล้ว

    Good tutorial :D
    but still confused, about Which file Laravel detected if the guard is admin or it was user ?.
    so that If I make more Auth example I had 5 User Level, such as "super-admin", "admin", "manager", "user", "user2"
    I can modified it.
    Should I make more prefix on route (web.php) ?
    or what.
    thanks

  • @Mike-iw4zc
    @Mike-iw4zc 7 ปีที่แล้ว

    thank you so much , awesome tutorial.

  • @denoldtimer1024
    @denoldtimer1024 5 ปีที่แล้ว

    In 5.8 the Exception handler function unauthenticated has been moved to the vendor/laravel/framework/src/Illuminate/Foundation/Exceptions/Handler.php
    So in the app/Exceptions/handler.php the function doesn't exist.
    Al you have to do is add it to override the base function in the vendor directory.
    Remember to add the use statements

  • @easyvideott7505
    @easyvideott7505 7 ปีที่แล้ว

    Hi Curtis, i just wanted to say that i already created something very similar but kind of another way around....i have created two different register forms and there in register controller i set the user if he is an admin or a regular user (depends on which register form they have used) so the login form is the same for any kind of users. And the users table is also where the admins are stored. I would like you to give me a feedback on this...want to hear your opinion on this. Is it good or bad practice?

  • @leagueofzed4903
    @leagueofzed4903 6 ปีที่แล้ว

    In case if anyone don't want the logged in user access the login form of admin, go to your AdminLoginController then change the showLoginForm function to this
    public function showLoginForm()
    {
    if(Auth::check()){
    return redirect('/home');
    }
    else {
    return view('auth.admin-login');
    }
    }

  • @leumasrodama2010
    @leumasrodama2010 7 ปีที่แล้ว +1

    Great tutorial. Hello alex. I can login on admin page. Also, validation is okay.
    But, for the Auth::guard('admin')->attempt, it does not display `Email and password mismtached` error. Please help. thanks

  • @kefir3d
    @kefir3d 7 ปีที่แล้ว

    Thank you vary much for excellent lessons! What about Part 4?

  • @axay_gadekar
    @axay_gadekar 7 ปีที่แล้ว

    Hi, thank you for all awesome series. I am trying this with laravel 5.5.*. And in this video i override the method unauthenticated and its works fine. is this right way to do unauthenticated redirects (in 5.5.*)??? if any other way to do it i am glad to know that.

  • @deogenesabejuelajr6701
    @deogenesabejuelajr6701 6 ปีที่แล้ว

    Fantastic tutorial

  • @yassinezorgati6762
    @yassinezorgati6762 5 ปีที่แล้ว

    Greaat tutorial man!! thank u so much , that's helped me a lot

  • @DenniS-qr3nn
    @DenniS-qr3nn 6 ปีที่แล้ว +2

    Why Auth::check();
    not working.. Always return false, even though I have login as someone from the above ?
    I'm implemented this method (part 1 - part 3) to Laravel 5.6
    Thx

    • @bansuanshop4023
      @bansuanshop4023 5 ปีที่แล้ว

      me too user can check but admin/login not working go to admin/login pasge

  • @somerandomchannel382
    @somerandomchannel382 7 ปีที่แล้ว +3

    app\Exceptions\Handler.php has shrinken ALOT since this video . Any tip how do this?

    • @naeemqaswar5037
      @naeemqaswar5037 6 ปีที่แล้ว

      Its true that Handler.php is shrinken but there is no reduction in its functionality, meaning you can always override the functions you were using before. Like *unauthenticated* is not there anymore but you can define it and use it to your will !

  • @余航-d3c
    @余航-d3c 5 ปีที่แล้ว +1

    I think that after clicking logout, it should return to the login page judged by user type. That is, admin returns to /admin/login and user returns to /home or /login page. And how to do this?

    • @mtzrmzia
      @mtzrmzia 5 ปีที่แล้ว

      did you solve it?

  • @ashishrprastogi
    @ashishrprastogi 7 ปีที่แล้ว

    Awesome tutorial and very well explained as usual. I have a request for a you. can you explain about after logout redirection ?

  • @kenxu5721
    @kenxu5721 6 ปีที่แล้ว

    Alex, how did you learn these in the first place? Laravel is like a black box to me, without your videos, I have no idea how to dig in these files.

  • @j4g094
    @j4g094 6 ปีที่แล้ว

    laravel 5.6:
    the app\Exceptions\Handler.php has been shortened but the "unauthenticated" method is still available in the "Illuminate\Foundation\Exceptions\Handler".
    as stated in laravel.com/docs/5.6/authentication#protecting-routes under "Redirecting Unauthenticated Users" you have to add the namespace "use Illuminate\Auth\AuthenticationException;" to your Handler.php and then create the "unauthenticated" method. The documentation shows the redirect with a ternary operator. I recommend you comment that one out and replace it with the code from alex' video.
    That's it.

  • @sadhanace
    @sadhanace 7 ปีที่แล้ว

    Excellent video

  • @surfinbird71
    @surfinbird71 7 ปีที่แล้ว

    Hey guys, if you download the source code on Github don't forget to add this code to AppServiceProvider.php:
    use Illuminate\Support\Facades\Schema;
    public function boot()
    {
    Schema::defaultStringLength(191);
    }
    // Do it before running the migrations.

  • @fadlihermansyah3866
    @fadlihermansyah3866 6 ปีที่แล้ว

    nice Tutorial.
    BTW this sound Horror, little bit Scared, 19:00

  • @ParsclickTV
    @ParsclickTV 7 ปีที่แล้ว +1

    Alex 11:30 admin.login didn't work for me i had to add route('admin.login') instead and I made the switch statement much simpler: $login = $guard == 'admin' ? route('admin.login') : 'login';

    • @codegeek8256
      @codegeek8256 7 ปีที่แล้ว

      where did you put this switch statement??

    • @elvisadjei2062
      @elvisadjei2062 7 ปีที่แล้ว

      It didnt work for me as well

    • @aliozen6681
      @aliozen6681 6 ปีที่แล้ว

      Didnt work for me as well. I dont understand why. Which line attempt to block that? Any suggestion to fix it?

  • @sergeyglebko6715
    @sergeyglebko6715 7 ปีที่แล้ว

    As far as I understand, when I click "logout" on /home or on /admin I log out of both my accounts (if I was logged in as user and as admin at the same time)?

  • @eberechionyechere4902
    @eberechionyechere4902 7 ปีที่แล้ว

    awesome tutorial

  • @ihorslavinskyi9823
    @ihorslavinskyi9823 6 ปีที่แล้ว

    Hi your videos are helpful, but I can't find your written instruction. Where i can find written instructions??

  • @mrarmani2079
    @mrarmani2079 7 ปีที่แล้ว +1

    can you show how you handle multiple roles and permission?

  • @jebbush2964
    @jebbush2964 7 ปีที่แล้ว

    Could you please finish and project at the time? Why don't you finish the blog website in Laravel 5.4 before you start creating other series?

  • @toddmcmannus1531
    @toddmcmannus1531 7 ปีที่แล้ว

    I love your tutorial. I have it completely working. My question is in my user table I created role. I have three different types of users in that table. I want to be able to have user1 redirect to user1.blade.php user2 to redirect to user2.blade.php and user3 to redirect to user3.blade.php upon logging in based on that field called role. How difficult would it be to modify this tutorial to make it do that?

  • @amilaupathissa
    @amilaupathissa 7 ปีที่แล้ว

    Hi,
    Could you please help me..
    I have installed Laravel 5.5 and try to do what you do in this tutorial series. But after doing all things, it doesn't redirect to the intended page when I use construct method with 'auth:admin' middleware in AdminConroller. What was happend there..?
    thanks.

  • @joebradfield
    @joebradfield 6 ปีที่แล้ว

    Alex have you done a tutorial on setting up a role based auth?

  • @chigozie_jesse
    @chigozie_jesse 6 ปีที่แล้ว +1

    if you are using version 5.5 or 5.6 use this instead in your app/Exceptions/Handler.php
    public function render($request, Exception $exception)
    {
    //gets the class exception
    $class = get_class($exception);
    switch($class) {
    case 'Illuminate\Auth\AuthenticationException':
    $guard = array_get($exception->guards(), 0);
    switch ($guard) {
    case 'admin':
    $login = 'admin.login';
    break;
    default:
    $login = 'login';
    break;
    }
    return redirect()->route($login);
    }
    return parent::render($request, $exception);
    }

  • @reantech4522
    @reantech4522 6 ปีที่แล้ว

    I Do love you and thank you guy

  • @xitemiru
    @xitemiru 5 ปีที่แล้ว

    hello ,i have a question with "protected function unauthenticated" on laravel 5.8 link address have change to vendor/foundation/exceptions/handler.php , if i do rewrite it every time i use composer update will replace the file any idea or anyway can solve this problem?