DEV Community

Laravel 8 Auth (Registration and Login)

Kingsconsult on September 17, 2020

Hello, how are you doing? Today, I am going to teach us how to do user authentication in Laravel 8. As you all know, the Laravel team released the ...
Collapse
 
marcellusgraceman profile image
marcellusGraceman

I have followed the instructions above.. I dont see the login button at the top of the homepage of Laravel application

Collapse
 
kingsconsult profile image
Kingsconsult

were you able to register successfully?

Collapse
 
marcellusgraceman profile image
marcellusGraceman

no.. I keep getting this error..page not found..even for login page

Thread Thread
 
kingsconsult profile image
Kingsconsult

I need to see your code is to where you are getting it wrong

Thread Thread
 
marcellusgraceman profile image
marcellusGraceman

can I send you a zip file of the project?

Thread Thread
 
kingsconsult profile image
Kingsconsult

you can push to github and share the link

Thread Thread
 
marcellusgraceman profile image
marcellusGraceman

ok

 
kingsconsult profile image
Kingsconsult

you might wish to send it privately to my email if the code is confidential

kingsconsult001@gmail.com

or reach me through my WhatsApp
+234 806 605 6233

Thread Thread
 
kingsconsult profile image
Kingsconsult

alternatively, we can use video chat, zoom

Thread Thread
 
getrackerdan profile image
GETrackerDan

Was there a solution to this issue? Running into the same problem with ' The requested URL was not found on this server. ' with login - register pages.

Thanks

Thread Thread
 
kingsconsult profile image
Kingsconsult

Yes, there was a solution, the error was a typo

Thread Thread
 
getrackerdan profile image
GETrackerDan

Could you elaborate? As facing the same issue as the OP.

Regards

Thread Thread
 
kingsconsult profile image
Kingsconsult

I mean, he misstyped something

Thread Thread
 
kingsconsult profile image
Kingsconsult

cause of the error might be different, but the error message might be the same

Collapse
 
seaklong_smarttech profile image
seaklong

this video can help you
youtube.com/watch?v=O36PNJr8UJg

Collapse
 
codingfix1 profile image
codingfix

Hi. A really nice post, thank you. I have a question: how can I customize profile adding billing and shipping addresses, for example? It's not just about customizing views but even the controllers. I could't find the Jetstream controllers nor a way to customize registration and/or profile as I told so I gave up and came back to the old Auth system which fortunately still works. But I'd like to know if there is a way to do what I said: maybe an idea for a future post? 😏

Collapse
 
kingsconsult profile image
Kingsconsult

Thank you for this, I will try to write about how to customize the Jetstream, follow on dev.to/kingsconsult , so you will not miss it out, but for the time being, the controllers for Jetstream can be found in app/Actions/ ,

Collapse
 
kingsconsult profile image
Kingsconsult

I forgot to reply, have written the material long ago, Customize Laravel Jetstream (Registration and Login)

Collapse
 
codingfix1 profile image
codingfix

Thank you so much. I'll follow you for sure

Collapse
 
seaklong_smarttech profile image
seaklong • Edited

this video can help
youtube.com/watch?v=O36PNJr8UJg

Collapse
 
zenahr profile image
Zenahr

Thanks for your post. I would love to have actual code snippets instead of pictures of code next time. That would be awesome.

I've followed all steps and ended up with something very different. The compiled Laravel app only comes with a Profile section, no API Tokens section. Also, there is no way for me to upload a profile picture. Could you link a GitHub repo with your code so we can reproduce exactly what you did in your tutorial with the correct dependencies?

Also, please update the guide by either saying explicitly which dependency versions you used or by updating to the current state of affairs. Cheers.

Collapse
 
kingsconsult profile image
Kingsconsult

Thank you Zenahr for your feedback, maybe you miss it, the repository for the code is in the write-up. However, in case you miss it, this is it github.com/Kingsconsult/laravel_8_..., I used Laravel 8.0, livewire 2.0, Jetstream 1.2.
If you still needs clarification, you are free to reach out, thanks

Collapse
 
sesughter01 profile image
Sesughter01

Hello Mr Kingsley. Thanks so much i was really helped by this guide. I just have a question i followed through your steps but had a different output when i ran "npm install && npm run dev" does this mean the build was not done properly? i uploaded a screenshot of the output. Thanks again

Collapse
 
vynxent01 profile image
vynxent01

I can't run (npm install && npm run dev) it gives me an error

At line:1 char:13

  • npm install && npm run dev
  • ~~ The token '&&' is not a valid statement separator in this version.
    • CategoryInfo : ParserError: (:) [], ParentContainsErrorRecordException
    • FullyQualifiedErrorId : InvalidEndOfLine
Collapse
 
kingsconsult profile image
Kingsconsult

I have not seen this type of error before, try running them one after the other, that is running the commands separately

npm install
and
npm run dev

Collapse
 
vynxent01 profile image
vynxent01

Got it! I thought I was going to run both commands at the same time LOL my bad thaaank you kingsley!

Collapse
 
anisahmmed profile image
Anis Ahamed

I am using jetstream authentication scaffolding in laravel 8. How to redirect different user to the different pages after login in this?

Collapse
 
kingsconsult profile image
Kingsconsult • Edited

if I understand your question, that is, you have different classes of users, you want to direct them to their dashboard on login.

  1. You can write a helper function, use if statement to determine what the function returns
  2. Go to RouteServiceProvider.php in app\Providers\RouteServiceProvider public const HOME = '/dashboard';, change the '/dashboard/' to the helper function
  • grab the user's id using Auth use Illuminate\Support\Facades\Auth; $id = Auth::id();
  • how do you determine the class of the user (different user)
Collapse
 
anisahmmed profile image
Anis Ahamed

. I have used this way but it's not working. Is there any way to redirect user by using middleware

public function redirectTo()
{
$role = Auth::user()->role_id;
switch ($role) {
case '1':
return redirect(route('dashboard'));
break;
case '2':
return redirect(route('judge_dashboard'));
case '3':
return redirect(route('user_dashboard'));
default:
return '/login';
break;
}
}

Thread Thread
 
kingsconsult profile image
Kingsconsult

Hello, sorry I missed your comment, have you resolved it? you can still reach out to me, if you have not

Collapse
 
uzairsheikh079 profile image
uzairsheikh079

i am getting the error in command prompt when i run npm install command error is "'npm' is not recognized as an internal or external command,
operable program or batch file"
even I have installed node.js in my system. please help me sir

Collapse
 
uzairsheikh079 profile image
uzairsheikh079

sorry i solved this issue but in my application there is no image upload and other options

Collapse
 
lauren_dorman_0dec7562c5e profile image
Lauren Dorman

When trying to reset password, google is blocking access to the emails. so no email is sent. Is there a way around this. This is the error:

Failed to authenticate on SMTP server with username "afafnoreply@gmail.com" using 3 possible authenticators. Authenticator LOGIN returned Expected response code 235 but got code "535", with message "535-5.7.8 Username and Password not accepted. Learn more at 535 5.7.8 support.google.com/mail/?p=BadCred... w25sm13431323wmc.42 - gsmtp ". Authenticator PLAIN returned Expected response code 235 but got code "535", with message "535-5.7.8 Username and Password not accepted. Learn more at 535 5.7.8 support.google.com/mail/?p=BadCred... w25sm13431323wmc.42 - gsmtp ". Authenticator XOAUTH2 returned Expected response code 250 but got code "535", with message "535-5.7.8 Username and Password not accepted. Learn more at 535 5.7.8
support.google.com/mail/?p=BadCred... w25sm13431323wmc.42 - gsmtp

Collapse
 
jltamolo profile image
Julie

hi, did you get a solution for this

Collapse
 
thedudetechnologies profile image
Rishit Nimavat

can we used customize view for login register and dashboard..?

Collapse
 
kingsconsult profile image
Kingsconsult

Yes, you can use any custom page for any of them

Collapse
 
robertlook profile image
Robert Look
Collapse
 
tunjiyr profile image
Tunjiy Ridwan

thanks for this boss

Collapse
 
kingsconsult profile image
Kingsconsult

🤛

Collapse
 
lengyelbalint profile image
lengyelbalint

Hello Kingsconsult! It works perfectly. :)

How can I send verification mail after registration?

Collapse
 
kingsconsult profile image
Kingsconsult

I just wrote an article on that, you can get the full tutorial here
How to send email in Laravel 8 downwards using Gmail

Collapse
 
richard4s profile image
Richard Oluwo

Definitely saved my day

Collapse
 
kingsconsult profile image
Kingsconsult

Wow, glad to hear that
😄

Collapse
 
pushpak1300 profile image
Pushpak Chhajed

Yes It is Right But laravel team has started support for laravel/ui

Collapse
 
gausoft9 profile image
Gauthier

Thanks for this post. How to customize the authentication views? I'am wondering how to override the laravel 8 auth system

Collapse
 
kingsconsult profile image
Kingsconsult

Thank you, it just depends on how much customization you need, you can choose to use inertia scaffolding over the livewire, then define your own view, but you can also customize the livewire. A view directory is created in your app directory, you can customize them, also in your resources directory, navigation-dropdown blade file is created, and layouts directory, all those files are what made up the views, you can customize them to your likings.

Collapse
 
kalecio profile image
Kalécio

Dude, finally. Thank you so much, I always got stuck in error after error with jetstream.

Collapse
 
surendra1993 profile image
SURENDRA BHARATHI

Nice Tutorial. I am trying to authenticate admin and users with the same login page and redirect to the admin or user landing page. How do I achieve this using Laravel 8 jetstream authentication?

Collapse
 
anmolparmar profile image
anmolparmar

Change our password and Enable two-factor Authentication
is not working without php artisan serve

Collapse
 
maxwell50002765 profile image
Maxwell David

Exception
The Mix manifest does not exist. (View: C:\xampp\htdocs\loginapp\resources\views\layouts\guest.blade.php)

Collapse
 
ismadevjs profile image
ismail taibi

How to customize the dashboard with your own styling ?

Collapse
 
lyphuthao profile image
LyPhuThao

Thank you so much bro!

Collapse
 
kingsconsult profile image
Kingsconsult • Edited

🤛

Collapse
 
mostafahaghi profile image
Mostafa-Haghi

Greate!
It works!
thanks alot

Collapse
 
hoshmandaqil profile image
Aqil Hoshmand

Hi dear, many thanks for you nice teach...
when I register a user and log out that , I can't login again , why?

Collapse
 
kingsconsult profile image
Kingsconsult

Thank you for the encouragement.
Check how you store (register) the password and also how you want to retrieve (login) the password, did you hash it the same way?
That might be a cause