Logging Out Users - Native Laravel 5.4 Multiple Authentication Series (Part 4)

  Рет қаралды 49,768

DevMarketer

DevMarketer

Күн бұрын

Пікірлер: 134
@sktfangirl
@sktfangirl 7 жыл бұрын
Just a small tip, you can call except directly from the middleware object like this: $this->middleware('guest')->except('logout', 'userLogout'); Instead of writing an array. Thanks for the tutorial!
@TahirBhai
@TahirBhai 7 жыл бұрын
Yes you can but the most authentic and futuristic technique is to use Array.
@renancoelho5657
@renancoelho5657 7 жыл бұрын
Whool! So much thanks to you guy! I 've created a complex and complete authentication system with 3 independents domains on my website. You can login into my website by using three independent sessions: send password recovery mail, login/logout, register, etc, etc. Thanks to your videos
@tangaye
@tangaye 7 жыл бұрын
How does DevMarketer pass the right route in the header to logout admin or user?
@sauryapaudelfr
@sauryapaudelfr 6 жыл бұрын
Can you help me with this? how to show session of either user on the same page. Suppose I have user and admin session, admin being the secondary auth, how to use admins session when user is not logged in for the pages where users session is stored and displayed.
@SaifulIslam-dn3tj
@SaifulIslam-dn3tj 6 жыл бұрын
Thank you so much , sir. This code not work properly in laravel 5.7. Please make a video what is the change in 5.7.... Please sir
@mephalanb30
@mephalanb30 7 жыл бұрын
Excellent stuff, many thanks, looking forward to the final instalment. For the benefit of anyone else who might have a bug at the end it took me a few minutes to spot I hadn't removed the request object from the copied logout function.
@tangaye
@tangaye 7 жыл бұрын
How does DevMarketer pass the right route in the header to logout admin or user?
@yuhanjiang
@yuhanjiang 7 жыл бұрын
Thank you, Alex! Your tutorial is always the best.
@spappas1986
@spappas1986 7 жыл бұрын
I used the @component to separate the navigation from layout.app and with the same logic that was used in the who.blade with the @if (Auth::guard('web')->check()) to set the URI to the different users/logout route and the admin/logout route. I had to change the route for both to "POST", and it works, but only if logged in as either user or admin, not both. At least this gets the logout functionality into the navigation link for both users and admin. Great tutorial!
@spappas1986
@spappas1986 7 жыл бұрын
It doesn't work with 3 different types of users. Any ideas?
@nooreekhayrattee1846
@nooreekhayrattee1846 6 жыл бұрын
One of the best tutorial...It really helped me..
@야씬
@야씬 6 жыл бұрын
Great tutorial, I would just like to know where I can find the written tutorial. I've checked the description but it says coming soon. I also would like to ask what the best practice is to hide the admin routes from any user.
@imranhadid8082
@imranhadid8082 5 жыл бұрын
Thanks a lot. I'm using laravel 5.8 actually this part 4 helps to remove all the errors.
@mtzrmzia
@mtzrmzia 5 жыл бұрын
it works for you?
@imranhadid8082
@imranhadid8082 5 жыл бұрын
@@mtzrmzia Yeah it works. watch and follow all the videos. hope it'll solve your problem
@mtzrmzia
@mtzrmzia 5 жыл бұрын
@@imranhadid8082 please upload to GitHub and let me fork :/
@imranhadid8082
@imranhadid8082 5 жыл бұрын
@@mtzrmzia Sure. I'll make a new repo and upload it tonight. I'll let you know
@mtzrmzia
@mtzrmzia 5 жыл бұрын
@@imranhadid8082 thanks. i will apreciate it
@peterballa6060
@peterballa6060 6 жыл бұрын
Thanks great video series! You helped me a lot to understand the guards. Now I dont have to separate admin-customers into different domains and I can share the configs, models and components etc.
@muhammadzeeshan07
@muhammadzeeshan07 4 жыл бұрын
hi there ALex, i want to know that if both admin and web users have data in there sessions, so when we logout as admin or user will that particular logout flushes the session data of that particular auth guard or not ,because it this video you suggest to remove that lines which refresh the sessions, and we know that guard drivers are sessions in auth.php
@aliprogrammer3644
@aliprogrammer3644 7 жыл бұрын
helloooo it is long time to see you again. please be sure we are waiting for you every day
@sangeeth810
@sangeeth810 4 жыл бұрын
professional teaching
@FarhanKhan-cp2kw
@FarhanKhan-cp2kw 5 жыл бұрын
How can I change the default @auth ... @endauth inside welcome.blade for Admins.....? I have no idea where to start looking...any guidance/suggestion is appreciated
@muhammadkamranjaved2424
@muhammadkamranjaved2424 7 жыл бұрын
Which syntax is use to fetch Admin ID in other controller? Will it be like this? $category->admin_id = Auth::guard('admin')->id;
@masetenicholas4520
@masetenicholas4520 5 жыл бұрын
This part 5 has been on coming soon for some good time now.
@sathisdhanasekaran6936
@sathisdhanasekaran6936 5 жыл бұрын
Thanks Man......You Save My Time..Thank For Knowledge.....
@richasugandhi2954
@richasugandhi2954 5 жыл бұрын
Hello, Auth::guard('admin')->logout(); Is not working on laravel5.7 version Please help me.
@АндрейПугач-э4р
@АндрейПугач-э4р 5 жыл бұрын
Did you find a reason?
@alihassan1753
@alihassan1753 4 жыл бұрын
you have not used "use Illuminate\Http\Request;" in your LoginController.php but running properly how ?on the other i got error please explain.
@TheBurf316
@TheBurf316 6 жыл бұрын
If you use the default welcome page and the template for nav of laravel, which is better to use bootstrap 3 or 4?
@aosm_llc
@aosm_llc 7 жыл бұрын
when I type logout in the browser it works, but when I use the Logout drop down at the top right of the screen, both users get logged out simultaneously
@xanthos733
@xanthos733 7 жыл бұрын
This behavior is normal if you wish to change it you need to edit it
@loremipsum574
@loremipsum574 7 жыл бұрын
Sir, do you have any solution for this?
@DaveSohan
@DaveSohan 7 жыл бұрын
Did you not watch this video??
@ahte15
@ahte15 7 жыл бұрын
Mmh well, you can do something like in your app.blade.php a href="(Auth::guard('admin')->check()) ? route('admin.logout') : route('user.logout')">Logout
@TahirBhai
@TahirBhai 7 жыл бұрын
You should remove the form from logout, because as you can see he just wrote a route with get for logout admin, so you need to just use anchor and put that route to the href and that is it. You should remove the onclick from anchor and also the form below the anchor. It might solve your problem.
@adewaleadeleye3165
@adewaleadeleye3165 7 жыл бұрын
I used this tutorial on laravel 5.5 and everything worked except that the logout for admin logout the user instead. There are few file modifications in laravel 5.5. The handler.php file has been moved to laravel>framework>src>illuminate>foundation>exception>handler.php. I used the following code when the sample provided was showing errors. $guard = array_get($exception->guards(),0); switch($guard){ case 'neutral': $login = 'admin.login'; break; default: $login = 'login'; break; } return $request->expectsJson() ? response()->json(['message' => 'Unauthenticated.'], 401) : redirect()->guest(route($login));
@loremipsum574
@loremipsum574 7 жыл бұрын
@Adewagold Adeleye, did you find a solution for this error?
@hellcchin4041
@hellcchin4041 7 жыл бұрын
Thank guys you save my day, salute!!!
@juanrincon6576
@juanrincon6576 7 жыл бұрын
Perfect, but what about a single login form and multiple users auth? i mean, Mod, Admin and common users. To log in on a single login form. Roles i think is the name
@aaronshed
@aaronshed 7 жыл бұрын
You might as well just have a database field for user type.
@andersonmartins3862
@andersonmartins3862 7 жыл бұрын
Alex, first of all I would like to thank you for the videos, congratulations for the great work! When I log in to both, when logging out an admin (example), the two sessions are terminated. Could you explain me how to change the logout method so this does not happen? Thank you!
@robdorn420
@robdorn420 7 жыл бұрын
I don't understand the benefits of multiple authentication over role/permission based authorization. Is the latter not more flexible?
@bubaidas6020
@bubaidas6020 5 жыл бұрын
If i open two login panel into the same browser but after login as admin or user if i logged in another then it going to the Page 419 | Expired. But when i refresh the page then it's working properly.
@tangaye
@tangaye 7 жыл бұрын
How does DevMarketer pass the right route in the header to logout admin or user?
@yonann7899
@yonann7899 6 жыл бұрын
I am got error with laravel 5.5 "Method [guard] does not exist on [App\Http\Controllers\Auth\AdminController]."
@leumasrodama2010
@leumasrodama2010 7 жыл бұрын
Hello. Why is it that after I log out on admin page, I can still access the admin whenever I click back on my browser? I expect that it will be redirected to the login of admin..
@HoangTran-qv9iw
@HoangTran-qv9iw 7 жыл бұрын
Thanks a lot . But i'd like to ask when Written tutorial comes out? I wanna read the doc to fully understand it, it is confusing! :)
@TanjilBhuiyan
@TanjilBhuiyan 7 жыл бұрын
Thank you for this video. i have a question default exception was like : ->except('logout'). but you used them as an array. default one does not work?
@JacurtisTutorials
@JacurtisTutorials 7 жыл бұрын
Both work. Lots of ways to do the same thing in Laravel
@yccodei
@yccodei 7 жыл бұрын
If I had multiple admins and each one have separate job_title, How could I separate them in controller so admin with administrator job_title can access some controllers and another admin with supervisor can access another controller? help plz
@midith316
@midith316 6 жыл бұрын
what IDE are you using in this video?
@pranavmandlik5852
@pranavmandlik5852 6 жыл бұрын
i tried same code but when i try to login with url /login it shows user login form and when i fill that form after successfully submission it redirects to admin/login page and when i try to enter url /home it show logged in users dashboard
@AJ3600
@AJ3600 7 жыл бұрын
At last you saw my email. ☺☺
@Shinerweb
@Shinerweb 7 жыл бұрын
when i remember me checkbox then username and password not save after logout
@agungngurahabhinaamitabha7463
@agungngurahabhinaamitabha7463 7 жыл бұрын
then how can we registered the new admin jac?
@mostafakawsarlive8574
@mostafakawsarlive8574 7 жыл бұрын
Thank you dear for log out part
@tangaye
@tangaye 7 жыл бұрын
How does DevMarketer pass the right route in the header to logout admin or user?
@virendraarekar539
@virendraarekar539 5 жыл бұрын
How to implement facebook like page creation and post in our app also big question is that how to maintain and regenerate token after first log in.No need to log in again and again for facebook app. Can you suggest me in one of those languages like node js or react or php.Please help me.
@vakasghulamnabi9259
@vakasghulamnabi9259 7 жыл бұрын
my session flash messages are not working after making guards and providers
@andorkonet
@andorkonet 7 жыл бұрын
Hi Alex! Can yout help me? I'm looking for best Atom packages. Could you tell me please what atom packages are you using and recomand it? Thans for help.
@petelukz342
@petelukz342 7 жыл бұрын
Bummer, I was hoping you’d go into a little detail on session expiration in logout. That’s a missing subject that has been difficult to deal with.
@chiragtelar9381
@chiragtelar9381 6 жыл бұрын
Thanks @alex your video is useful for better learning once again thanks alot. :)
@vincelouiechu6702
@vincelouiechu6702 7 жыл бұрын
Hello. How can i show the error message if the credentials does not match on records just like default login. And how about if i want user and admin to access the page .. just like this public function __construct() { $this->middleware(['auth:web'], ['auth:admin']); } . Thanks
@GurvinderSingh-bz9ys
@GurvinderSingh-bz9ys 4 жыл бұрын
Does your part 1,2,3,4 works with Laravel 7? And Is Part 5: Forgot My Password Functionality across Multiple User Types """COMMMMING"?
@creativeworks98
@creativeworks98 6 жыл бұрын
Great video! Thanks a lot
@ramirotapia2217
@ramirotapia2217 6 жыл бұрын
Saludos Iám from Chile and i find your videos great keep it up
@FarhanKhan-cp2kw
@FarhanKhan-cp2kw 5 жыл бұрын
Please tell me the name of the Sublime Text Theme you are using!! Thanks in Advance
@user-ub6yo7mg1n
@user-ub6yo7mg1n 5 жыл бұрын
One Dark
@waldo21m
@waldo21m 6 жыл бұрын
Hi Alex, Thanks for share the videos :D saludos desde Venezuela :D
@ajaymasurkar5909
@ajaymasurkar5909 7 жыл бұрын
Hello sir I want to understand basic of middleware ,auth if any video about this please share link Thanks
@DazzyDude00
@DazzyDude00 6 жыл бұрын
The problem I'm having, is that it logs me in only after second attempt, when I try to login to admin first time, it redirects me to user login, but if I try to login again it works, same for the user
@tecocode6070
@tecocode6070 6 жыл бұрын
It doesn't work on laravel 5.6 I can't figure it out how to log out with your method
@rivalcorps
@rivalcorps 7 жыл бұрын
long time no see alex lol
@Msharulazwan
@Msharulazwan 6 жыл бұрын
Hi Sir, i follow your tutorial from part 1 until part 4, and i have trouble with Auth guard. Let say i use @if (Auth::guard('web')->check()) Logout user @else echo Logout admin @endif but if user and admin is login in same computer, the first if will be always true. So how to solve this problem ? Sorry for my bad english.
@saurabhparekh9857
@saurabhparekh9857 7 жыл бұрын
It is great tutorial. I have two guards name vendor and admin. If I logout from admin guard and try to login from vendor guard with same browser it first redirects me to admin login page. if i go back in browser and refresh the page it redirects me to vendor dashboard. Same issue if logged in as vendor and logout from it. Now try to login in admin guard from same browser it redirects me to vendor login if I go back and refresh page it redirects me to admin dashboard. I had follow all your method for login and logout for multiauth. it works with different browsers. I don't able to find issue with session or something in same browser. can you help me with this?
@RobertNicjoo
@RobertNicjoo 7 жыл бұрын
please show how to make second register form for other type of users, I followed this series now my auth:users are just user but i also made companies user the login system works perfectly as you teach in your videos but register form keep giving error and you don't have that part in your videos. Thanks.
@JacurtisTutorials
@JacurtisTutorials 7 жыл бұрын
As of right now, we already have two different register forms, that we did earlier in the series. You can customize the look of them however you want in the view files.
@RobertNicjoo
@RobertNicjoo 7 жыл бұрын
as you said in earlier of part 2 video is not worth to showing! now that I made my second register form with all different fields when i try to register as my second type of users which has to save in different table and not the users table will get error of "Type error: Too few arguments to function App\Http\Controllers\Auth\CompanyRegisterController::create(), 0 passed and exactly 1 expected" I would be appreciate if you show us how to register second type of users (allow them to register). PS: we have 2 login form in this series not 2 register form.
@DjVinny1015
@DjVinny1015 6 жыл бұрын
Your routes for logout must me set to POST, not GET, and once this is accomplished for some reason, logging out of user takes you to /admin
@DjVinny1015
@DjVinny1015 6 жыл бұрын
it seems my guard is showing 'admin' on the user page
@BalGopalLalShrestha
@BalGopalLalShrestha 7 жыл бұрын
I need to redirect admin logout to admin login page but this code is not allowing me. Can you help me out in this?
@7osSam52
@7osSam52 7 жыл бұрын
just go to the AdminLoginController and find the method called logout, and set the return to : return redirect(route('admin.login')); // where admin.login is the name of the login route for your admin
@kebonbaba7209
@kebonbaba7209 3 жыл бұрын
perfect
@KamranBhutto
@KamranBhutto 7 жыл бұрын
Thank you, Alex :)
@rohmatmret8265
@rohmatmret8265 7 жыл бұрын
any one can tell me , Why function logout(){ Auth::guard('web')->logout(); } thanks
@crisperlawas2968
@crisperlawas2968 6 жыл бұрын
where is part 5?
@erosmarcuszamora8828
@erosmarcuszamora8828 5 жыл бұрын
It works fine on Laravel 5.7 guys. Maybe you need to re-watched the tutorial if you have an error. Btw I didn't use the array in 'public function __contstruct()' part in both controllers This is my code: in LoginController.php public function __construct() { $this->middleware('guest')->except('logout', 'userLogout'); } in AdminLoginController.php public function __construct() { $this->middleware('guest:admin')->except('logout'); } I'm sharing this because this is the part where my error is, but fixed when I didn't use the array in 'public function __construct() ' part in both controllers. Hope this will help you guys.
@spacingouty09
@spacingouty09 7 жыл бұрын
After login as custom user like admin, whenever I want to direct to other pages and call {{Auth::user()}} doesnt work
@jackwander
@jackwander 6 жыл бұрын
Same problem here.
@yassinyoussoufali6324
@yassinyoussoufali6324 6 жыл бұрын
We miss you 😭
@djebirihamza1098
@djebirihamza1098 7 жыл бұрын
hey ! i want use this methode {{ Auth::user()->name }} for 'admin' in welcome page so , Where and what should I change? thank's for your help ^^
@JacurtisTutorials
@JacurtisTutorials 7 жыл бұрын
Auth::guard('admin')->user()->name should do the trick
@djebirihamza1098
@djebirihamza1098 7 жыл бұрын
thanks alot for your help man it's working :D
@kylecastillon9873
@kylecastillon9873 5 жыл бұрын
alex ,I cant log out my admin user please help
@nidaakram5157
@nidaakram5157 7 жыл бұрын
Hey i have a problem that is whenever I write wrong password it does not show me the message of wrong password instead of this it shows error under my username. Please tell me how to solve the problem
@mjackz
@mjackz 7 жыл бұрын
Hi, to show a message of incorrect password in the admin/login page, you could add ->withErrors at AdminLoginController@login // if unsuccessful, then redirect back to the login with the form data return redirect()->back()->withInput($request->except('password'))->withErrors(['email' => trans('auth.failed')]);
@H11Hverse
@H11Hverse 5 жыл бұрын
Great tutorial. I now Understand multi auth in laravel. I think the use of component is unnecessary in this part. you can only include the who.blade.php file.
@cromartie1984
@cromartie1984 7 жыл бұрын
can't logout of my admin, someone knows why ?
@goldenwings4230
@goldenwings4230 6 жыл бұрын
user logout function its not working
@hmairihalim1162
@hmairihalim1162 6 жыл бұрын
try this without ->except() : $this->middleware('guest', ['except'=> ['logout','userlogout']]); work for me
@SJ-ev6qf
@SJ-ev6qf 7 жыл бұрын
DevMarketer i had problem with Auth::user(), its returning null
@yavuzkoca8352
@yavuzkoca8352 7 жыл бұрын
To use it, you need to login first
@SJ-ev6qf
@SJ-ev6qf 7 жыл бұрын
Yavuz Koca i have logged in with admin bt while trying to upload a file i have to take the reference of user id but auth::user() is returning null also i have maked session to be remembered while logging in.
@yavuzkoca8352
@yavuzkoca8352 7 жыл бұрын
Can u try this: Auth::guard('admin')->user()->name
@SJ-ev6qf
@SJ-ev6qf 7 жыл бұрын
Yavuz Koca solved not by your method hope your method would worked for me. By the way thanks for helping and responding to my problem.☺️
@JacurtisTutorials
@JacurtisTutorials 7 жыл бұрын
If it is returning null then it means a user is not logged in. You probably want to use Auth::check() to see if a user is logged in before you use Auth::user() or protect your route in middleware so only logged in users can see that page.
@Tuanna94
@Tuanna94 6 жыл бұрын
thanks you very much
@portesbruno
@portesbruno 7 жыл бұрын
very good
@LearnPHPaz
@LearnPHPaz 6 жыл бұрын
Thank you !!!! :)
@trying2bepotatodeveloper869
@trying2bepotatodeveloper869 7 жыл бұрын
How to keep track of online users? :D
@syedanam1131
@syedanam1131 7 жыл бұрын
Attention please, when i logout as an admin user from Logout button. here also logout from normal user. that means, both users(admin & normal user) are logout by only one click.
@loremipsum574
@loremipsum574 7 жыл бұрын
Same problem here.
@dankelly
@dankelly 6 жыл бұрын
Where's part 5? 😁
@dankelly
@dankelly 6 жыл бұрын
I found it... Had to search for the series. Thanks for the great videos! Super helpful!
@sparrow8073
@sparrow8073 7 жыл бұрын
thanks
@advikpatel7004
@advikpatel7004 6 жыл бұрын
remember me not working properly.............please provide one tutorial for multiple authentication remember me
@PaoPaoPH
@PaoPaoPH 7 жыл бұрын
ty
@ashburnett891
@ashburnett891 5 жыл бұрын
I had some issues with the logout, and I also had issues with Remember Me, see how I fixed it here: github.com/DevMarketer/multiauth_tutorial/pull/28
@jacklindcosta6740
@jacklindcosta6740 3 жыл бұрын
resources\views\layouts\app.blade.php For dynamic logout, means Logged user will get desired logout route replacing the default logout @if(Auth::check()==1) @if(Auth::guard('admin')->check()) {{ __('Logout Admin') }} @elseif(Auth::guard('web')->check()) {{ __('Logout User') }} @endif @else Not logged in @endif
@uonick
@uonick 7 жыл бұрын
Atom: New file -> components/who.blade.php ;)
@VURGINN
@VURGINN 7 жыл бұрын
Sup
@JacurtisTutorials
@JacurtisTutorials 7 жыл бұрын
Hey
Мясо вегана? 🧐 @Whatthefshow
01:01
История одного вокалиста
Рет қаралды 7 МЛН
It’s all not real
00:15
V.A. show / Магика
Рет қаралды 20 МЛН
Junior Code Review: Laravel Routes, Middleware, Validation and more
19:57
Auth Multi Roles Login with Custom Middleware in Laravel 9
16:50
Cambo Tutorial
Рет қаралды 53 М.
How to Vim in 2023: Tips and Tricks
15:53
ThePrimeagen
Рет қаралды 444 М.
Laravel User Image
20:38
devdojo
Рет қаралды 136 М.
Laravel 8 REST API With Sanctum Authentication
54:13
Traversy Media
Рет қаралды 552 М.
Bash vs ZSH vs Fish: What's the Difference?
13:32
Eric Murphy
Рет қаралды 197 М.