Laravel Auth::attempt($credentials) not working | How to login with user email and password tutorial

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hello everyone are you experiencing this hot colon colon attempt and then uh your credentials is always returns false even though these credentials are correct let me go ahead and show you uh here these credentials are correct but if I try to login it outputs error because of this this is outputting false then else statement will be executed so what we have to do I am going to just come in these and then you might have the model of the user here in the models folder you will have the module for user table you have to Define what is your table name you might have in different table names that's why we are specifying this protected dollar table equals and this table name so you can provide you a values in this fieldable array okay now that that's it now we can open the controller again here what I will do just go ahead and create a instance of a user dollar user is equals to use the motor now firstly make sure you have imported your model Here app backslash models backslash user and then I will say where I'm going to set parentheses inside parenthesis firstly I am going to say email comma single quotations Echo symbol comma here we have to pass our email so that you might have some post request so we can say dollar request and then the field it will be the name that you provided in your view component in this case I am having email now uh here we can put semicolon and after that I'm going to say if we statement firstly I am checking this user is existing with dollar user and I am going to use and condition that means user should be existed and I am checking the password now if you are using any hashing in your uh database you can use the hash here this hash colon colon check okay now in order to use that we are going to say use illuminate backslash support backslash packets backslash okay now in this case we don't have to use that hash but let me check what's going on here I'm going to put parentheses inside parenthesis firstly I'm going to pass in my post data which is the password I will say request dollar request and I will get the password Here we don't need this array so I can come in that and also I'm going to put comma here after this chord then I am going to say dollar user and I am checking it is password here in user model our password is starting with capital p that means here we should put capital P and password okay now what happened I'm going to uh put braces and I will say a message before I am going to do sign in I will say success here and also I will add some AC statement to detect login fail though user doesn't exist so I can say error here this is not uh complete code but I want to check whether everything is working the next step is restart your application by press Ctrl C you can cancel the current process of running and you can relaunch PSP Artisan serve and after that here when we are selecting our user we have to say hyphen angle bracket first parentheses okay now it is fine now we can go ahead and restart this here it produce error this else statement now that because I am checking this hash but in my database I'm not using any hash so what I will do just remove this hash you only have to use that when you are using a hash and then I'm going to say this checking with the request password is equals to this user password so what I can do just refresh my page and click login okay it's produce success now uh the next thing I will do I'm going to commit this here we can say auth colon colon login the thing is if you are using that auth you have to import this illuminate support packets auth or okay and then here inside parenthesis I am going to pass in my user now how we can check whether login is success now the next step is check user is logged in for that I can use if statement inside parenthesis I will say auth colon colon check and then parenthesis now if user login in this if statement will get executed so I can say something like uh return success here this is the place that you are going to do redirection or whatever you want else statement will produce not locked in now we are going to check by running again here you can see success success means this every statement is executed because user is logged in now I hope this video helps and you will find these chords in the document that I attach in the description so don't forget to subscribe thank you very much
Info
Channel: Coffee Programmer
Views: 6,069
Rating: undefined out of 5
Keywords: laravel tutorial, laravel, laravel 8, laravel authentication, laravel auth, laravel login, laravel login tutorial, laravel 7, laravel 8 tutorial, laravel auth admin and user, laravel 9, login in laravel, laravel login and registration, laravel for beginners, laravel admin user, ban user in laravel, laravel login user, laravel 9 auth, laravel ban user, laravel login system, laravel user login, user login laravel, laravel project, login system in laravel
Id: dq0LTy89HVg
Channel Id: undefined
Length: 8min 14sec (494 seconds)
Published: Tue Feb 28 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.