(Part 2) Logging In Multiple Users - Native Multi Auth in Laravel 5.4

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

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

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

    I am a programmer from Brazil and even though i am not fluent i can understand the content perfectly!
    You are too much a teacher!

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

    I almost lost hope implementing multi auth in laravel, clutching at bogus tutorials and hitting dead ends until I saw this tutorial and everything changed. Thank you Alex, keep up the good work..

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

    Been struggling with Admin authentication for days until I found this lesson. Thanks so much!!

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

    Thank you very much you are one of the best teacher and laravel programmer in the world man

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

    @DevMarketer thank you very much for this walk through. Very informative and professionally done. I just wanted to add my 2 cents after struggling with custom multiple auth controllers, guards and middleware. I believe it is important to avoid overriding built-in Laravel functionality where possible, from many reasons but the most important one is to that you minimize the risk that your authentication will break in future versions . I've found that Instead of re-creating the whole login method inside the controller (which is inherited from the `AuthenticatesUsers` trait), it's easier to add a `guard` method to the custom login Controller that returns `Auth::guard('admin')`- this assumes that the credentials field names are the same of course. This way we use the build in login method and if it ever gets changed in the framework nothing breaks (my project starts as early as Laravel 4 an I saw way too many changes to the authentication methods). Hope it makes sense and helps someone. Keep up the good work!

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

    I'm just learning Laravel , and this tutorial was very useful to learn how to make a good login and then implemented in on my app ^.^, Greetings from Mexico !

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

    Thank you very much for these tutorials about multi-auth. You made the most straight forward and easy to understand tutorials on this topic and I have seen many. Your way of explaining things is very good and you are definitely well prepared!

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

    Hey You are awesome. The way you explained everything makes understanding so easy. Thanks for creating such helpful series.I have gone through number of other tutorials but finally i found you the best.

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

    Clear. Professional. Perfect. You're my first choice for Laravel.

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

    Man, cool videos! I was looking to this kind of tutorial like 3 weeks! I'm nooby with laravel so this will be so useful to me.
    By the way, I noticed you used to get some files going through the files. I think you're using Sublime so you can hint CTRL+P and type the file you are looking for. That could be save you a few seconds on your videos.
    Keep working like this, man! You're going great!

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

    It is super important to use throttling security for multiple login attempts for a website that is live on the internet. Bots are constantly searching for websites that the bots can use password rainbow lists and brute force to get in to your site. My suggestion is to never ever remove throttling features from Laravel. You must be meaning that you wont be creating the error pages and the user support for displaying timeout throttling messages etc. My guess is that you are focusing on creating the login part and not UI for throttling errors. I think its important that you make that clear to the viewer. Maybe put a little disclaimer box in the video.

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

      What is a throttling feature?

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

    login page is unable to display . it shows error 'ReflectionException (-1)
    Class App\Http\Controllers\Auth\AdminController does not exist'
    please am using laravel 5.8.This tutorial is really indeed a great tutorial.keep it up Devmarketer

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

      i have the same problem did u already find a solution? because i didnt :(

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

      if you really want to create multi auth in laravel, you will need to copy your User.php file and rename it.follow these process:

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

    Watching this now, because former employee used this in 2 real projects and now I need to modify that projects. He linked me here.

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

    actually finding contentment in learning new cool multi auth functionality.

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

    Really good video. I would recommend to anyone trying to learn more about laravel login in general.

  • @JD-hq1kn
    @JD-hq1kn 5 ปีที่แล้ว +1

    That creepy sound at 14:53 and that mysterious look following it.. LOL :)

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

    Your teaching skill is super......Thank You man

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

    perfecto, no hablo ingles y entiendo muy bien lo que transmites, excelente!

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

    Thank you. Your first video made me realize of something. :)

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

    Thank you, that was just what I needed. Awesome, keep up the vids!

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

    Thank you very much your video series help me a lot to make my project but you have used 5.x of laravel version and it also work in laravel 7 in my case thanks again

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

    this is immeasurably helpful. Thank you so much

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

    Your videos are helping me a lot. Thanks Man.

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

    For people who face the error Auth::guard
    please check the middleware of construct
    make sure guest:admin not guest::admin
    Because, i faced it too.

  • @syedm.hharis3009
    @syedm.hharis3009 4 ปีที่แล้ว

    if any of you is having error, just download the source code from github and past it in your project.
    especially in you Auth.php and adminlogincontroller

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

    Thank you sir... Very helpful tutorial.. exactly what i was looking for

  • @ЕвгенийД-я9ц
    @ЕвгенийД-я9ц 4 ปีที่แล้ว

    Friend, I would give you more likes if it could be done. Very cool and useful video!

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

    Thank you so much, what a beneficial video. Note! In your video descriptions, Part 1's links are wrong. Thank you again.

  • @AlexCrocker
    @AlexCrocker 7 ปีที่แล้ว +8

    This is SO helpful! Thank you.

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

    dude first video's link is incorrect, please correct it. you are owersome becouse explanation is fantastic

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

    Thank you for helping me get my degree :)

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

    Thanks a lot for share your skills with us
    The force will be with you

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

    i love your video i get all the time what i need nothing more fancy which make confusion...

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

    going very good.waiting for your next tutorial.

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

    Excellent..... You just made my day

  • @jezzymichelleirarelevo971
    @jezzymichelleirarelevo971 6 ปีที่แล้ว +4

    I've tried this but the logout isn't working anymore for both user and admin. How to fix that?

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

      I don't know how the logout worked out in the time of this video. But now, it only logouts from the default guard. I have solved it by redefining the logout() function in the LoginController (copy paste from AuthenticatesUsers trait) and added this step after the original (default) logout: Auth::guard('admin')->logout();

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

    Hey, great tutorial! you explain everything really well,
    1) I do have minor problems though it seems to me a few other viewers have the same problem but it has not been answered.
    so when you are at admin/login then you enter your details for admin it should redirect to another page (admin.dashboard). instead it takes you back to the same page(login form), after troubleshooting abit even if you enter a wrong password it does not show any errors which is odd as the register page works fine and shows errors when one occurs.
    what would you do to fix these problems?
    2) I would like to use the admin table for admins to register themselves but after messing around i cannot find which bit to tweak to direct the register logic to admin table instead of the users one.
    Thanks

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

    32:15 btw thanks for this video its really helpful.

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

    thanks, boss I was looking exactly like that it's working for me in front end and admin both in laravel 5.7

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

      it works in the part of validating the login fields?

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

    Hi Great tutorial!! got my Multi Auth implemented

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

    I love you men, muchas gracias por fin pude solucionar el problema del logueo con otro usuario

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

    dude, you are awesome .. I really appreciate you efforts .. thanks

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

    Thank you so much great tutorial helps me a lot

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

    Hi,
    Great tutorial!! got my Multi Auth implemented. Just one question:
    How can I redirect the admin logout to the admin login page ?
    Thank you!

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

    Thank you so much for sharing!

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

    All of this is nice, but woudnt be just easyer on the LoginAdminController simply call a method guard from the AuthenticatesUsers controller and set it to the 'admin'
    /**
    * Get the guard to be used during authentication.
    *
    * @return \Illuminate\Contracts\Auth\StatefulGuard
    */
    protected function guard()
    {
    return Auth::guard('admin');
    }

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

      ~Hi Mauro. I'm not able to login in with this code on the admin login. It seems it fails the login becaus i get redirected to the admin login page with the email data. So that autentication is not successeful i don't know why. How can i implement your solution?

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

    such a nice tutorial!!! subbed! keep it up lad

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

    This example is like someone would put the laravel documentation on road and with steroids. These videos are the shit.

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

    Hey Alex, learning the most from your videos. Just letting you know the video link for part 1 is incorrect, it's directing to part 2.

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

    is it ok to use middleware in web.php?
    like Route::group(['prefix' => 'admin', 'middleware' => 'auth:admin'],function () {}
    I think its more clear than controller

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

    your video is awesome!. hello from Japan!!

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

    when i uncomment
    //$this->middleware('guest:admin'); in admin controller then it redirected to login page after login from admin login please help

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

    Thank you for this series! Any idea when part 4 will be available?

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

    Very informative! Hats off

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

    Hey! I have been following "How to build a blog" series, but using laravel 5.4. So when it comes to authentication parts (part 27) I decided to follow this tutorial instead because of the differences between the version that is used in that tutorial and version 5.4.
    So, right now doing everything in this video got me a
    "FatalThrowableError in AdminLoginController.php line 25:
    Class 'App\Http\Controllers\Auth\Auth' not found " error.
    What is causing this?

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

      Fixed it: Added "use Illuminate\Support\Facades\Auth;" in "AdminLoginController.php"

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

      thank you sir. you are very helpful!!!!

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

    Many thanks sir.

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

    great work! thank you. Can you please create written or video tutorial for complete e-commerce project.

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

    i thought this was part 1 no wonder why i feel like missing something, this is part 2 of the series -_-

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

    Just some notice, you are repeating code, because we use AuthenticatesUsers Trait just call method $this->validateLogin($request);.
    Same with Auth attempt - just type $this->attemptLogin($request). If you are not use AuthenticatesUsers Trait - use it

  • @NazrulIslam-iz6sw
    @NazrulIslam-iz6sw 4 ปีที่แล้ว

    why we using 2 different routes for 2 types of login??
    we should have the same routes for login for both user and admin.
    while checking data from database, we should check from both table & based on that we will divide either as user or admin.
    How to do this?

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

    Hi,
    thanks allot for your time and marvelous channel.
    looked everywhere on how modal login will work with Laravel, but not success. hope that you cover or guide this area.

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

    @DevMarketer so i needed to implement this on my final year project at school and i happened to find this.
    now, everything works from part one but in part two when in input the credentials for the admin, it redirects me back to the adminlogin page. some people had these erros. was the a solutions or can you help me put here?

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

    i got a bit problem although all code is same. After logging out from
    admin if I try to go to admin login page ,it redirect to admin
    dashboard . why this is happening?? Any idea ?? After remember option enabled i got this problem. May be session is not flushed while logging out from admin if remember me option is checked. Any help??

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

      same thing happened to me , but if you remove the :admin from
      $this->middleware('guest:admin');
      in AdminLoginController
      it works, I don't know why though

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

    Very good tutorial. Thank you

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

    Thank you for your helpful content

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

    very interesting tutorial very helpful

  • @mraees4958
    @mraees4958 7 ปีที่แล้ว +15

    hi, the only problem i am facing is that it is not directing me to the 'admin dashboard' . Even with correct password ....? what should i do ? plz help soon

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

      Experiencing the same problem with laravel 5.3. Did you figure it out?

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

      Make sure the columns in the database are in small letters, the input names on your forms in small letters too, also make sure this matches the input fields in your controller. I did this and it worked for me.

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

      I have the same problem did you solve it ? @mark

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

      Yes , i have figured out the issue. the password must be encrypted and then save into your database. it should not be enter manually. Either use 'Tinker' to save username or password. or in your 'Controller' use this to save the password = $clinics->password = bcrypt($request->password);... $clinics is a object name ... password is a column name in my database and this line of code is bycypt($request->password) is where i am taking request from the textfield. hope this helps ! Good luck!!

    • @mahmoudahmed-di6wl
      @mahmoudahmed-di6wl 7 ปีที่แล้ว +2

      ok it is worked thanks @mark

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

    Wonderful tutorial

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

    why is this not working ?
    Auth::guard('admin')->attempt(...................) // admin using passport as the driver

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

      go to config/auth.php and make sure you set your admin guard driver to session and not token, Hope it helps

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

    Hi, Your video is very helpful the only problem i found is, when accessing /admin without login, it is redirecting me to /login page. It should login to /admin/login ..... hope you understand my concern and will get your answer soon.

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

    Man, I love your videos. It helped me so much on my works.
    Little question.... Which editor are you using? Don't need to be him to answer. Anyone knows?

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

      That's Atom

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

      Ken Xu thanks man

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

    Thank uu man ur tuto helped me a lot thankss

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

    Excellent! Also work with laravel 6

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

    hello...may I know how to differentiate admin and user registration.when I register it is saving into user table but not admin table based on your tutorial.

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

    This is SO helpful! Thank you. thanksa ton

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

    whats the difference between using auth middleware in the routes grouping and in the controller? I personally prefer it in the routes list

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

    Very useful! Thanks!

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

    Thank you so much, a very nice video.

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

    Thank you..Thank you...Thank you.....Thank you...Thank you....

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

    Hi There, I have got multi auth working thanks to this tutorial. Access, however, seems to be a bit of a problem. I have a controller that needs to be guarded by both, user and admin, meaning that only these types of users can access this controller, but every time I use one guard in __construct(), the other cannot access it. I even tried $this->middleware(['auth','auth:admin']) and both types got blocked from accessing this controller. Thank you already for this great series.

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

    I know it's an old video, but I have a question Alex : I can't log 2 different types of users in the same time. When I'm loggued in with an admin, as soon as I try to log with a customer, the admin is loggued out. Do you have any lead (maybe you've faced the problem at one point) of the issue ? Thanks (you do awesome videos!)

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

    I have problem when i click button member login. the rror is "Class '\App\Members' not found", please help me...

  • @aniszulaikha8953
    @aniszulaikha8953 ปีที่แล้ว

    I need help, when I login as admin, it does not displays the admin name on the top nav bar. Can someone help. Thanks

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

    AuthenticatesUsers.php file not appearing Laravel Framework 7.7.1 (vendor/larvel/framework/src-illuminate/foundation/auth/AuthenticatesUsers.php file not appearing) please advice.

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

    why should i create an admin table, just for one admin account. I'll go for role based logged in using "users" and "role"

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

    really good videos :)
    i´m hoping it still works with laravel 5.7

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

    Firstly thank you so much. I have a query. Tinker gives error 'Class 'Illuminate\Foundation\Auth\Admin' not found' when I try to create a new admin as you did. So, I had to create an Admin class similar to User class in this directory. Then it works. Is this the correct way?? Please help.

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

    Hey, Alex. Nice tutorial, but I'm wondering why are you copying just a part of AuthenticateUsers trait when you can use it in your AdminLoginController and just add the guard() method that specifies the guard against which you want to log the user (well, admin in this case) in? It's just one method call and you get all the goodies the trait comes with... I did it that way and it works. Any ideas if this is wrong on my side?

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

      Yes i changed my code too at the end, but i think it is good also the way he showed it to us. Personally it helped me to understand some behind the scenes stuff better.

  • @firojkhan-kv1ew
    @firojkhan-kv1ew 6 ปีที่แล้ว

    sir getting this error
    The Response content must be a string or object implementing __toString(), "boolean" given.
    how it will solved

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

    when password resets are coming?
    very awesome tutorial Alex.. thank you..
    please make a video on multi role users.. please.. or extend this series... thank you.

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

    Excelent job! Thanks!! You are a genius! can you recommend me a book?? Greetings from Argentina!!

  • @md.shafayatulhaque6273
    @md.shafayatulhaque6273 6 ปีที่แล้ว

    Great tutorials

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

    i love it.

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

    Thank you Sir It's really helpul to me Thanks a lot Sir..

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

    hi, how can I get the name column in Admin?, because with user is:
    $user = Auth::user()->name;
    thanks in advance

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

    It says app/models/Admin models not found in laravel 8. can you help me?

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

    Hii, I am having a problem during ADMIN login as login page is not redirecting to dashboard as Its getting unsuccessful and going back to login page. Please help.

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

    Whats weird is that if i log in as admin it lets me log in again with the user login and after those 2 login form it routes me to admin dashboard

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

    Thanks a lot ma man

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

    Hello
    I think that's not good idea to create Model, Table ..etc for each role, and why do you not use juste one Model and switch with roles field or table joint !! Drupal authenticate logic for example

    • @Marco.Hochmuth
      @Marco.Hochmuth 7 ปีที่แล้ว +1

      Watch the first video, the first minutes. this is a very example that not would need this duplications - its all about the cases where you actually want to have this functionality - but you are struggeling and want to watch someone implementing it.