Ready to get started?

Join Adocasts Plus for $8.00/mo, or sign into your account to get access to all of our lessons.

robot mascot smiling

Logging In Users & Displaying Exceptions

In this lesson, we'll add the ability to login to our application. We'll then discuss the differences between errors and errorsBag and how we can display long-lived exception messages as an alternative to our toast manager.

Published
Oct 11
Duration
10m 40s

Developer, dog lover, and burrito eater. Currently teaching AdonisJS, a fully featured NodeJS framework, and running Adocasts where I post new lessons weekly. Professionally, I work with JavaScript, .Net C#, and SQL Server.

Adocasts

Burlington, KY

Chapters

00:00 - Adding our Login Form
01:58 - Defining Our Login Routes & Discussing Redirect Behavior
03:30 - Login Validator
05:08 - Defining our Web Login Action
06:18 - Defining our Login Controller Methods
07:12 - Testing Our Login
07:30 - Errors, Exceptions, & Long-Lived Alerts

Ready to get started?

Join Adocasts Plus for $8.00/mo, or sign into your account to get access to all of our lessons.

Join The Discussion! (8 Comments)

Please sign in or sign up for free to join in on the dicussion.

  1. Commented 2 months ago

    Hi Tom, please can you do a section on how to log users in with Google?

    1

    Please sign in or sign up for free to reply

    1. Commented 2 months ago

      Hi Carlos! Yes, I've been meaning to record a lesson on that! Perhaps I can get that recorded this upcoming weekend for release soon after.

      1

      Please sign in or sign up for free to reply

  2. Commented 15 days ago

    Hi Tom,

    1) Is it possible to prevent the browser from displaying the "Save Password" popup when invalid credentials are submitted?
    2) When long-lived alerts for invalid credentials are displayed, they persist even after navigating to another page (e.g., the "Forgot Password" route) and returning. How can this issue be resolved?

    1

    Please sign in or sign up for free to reply

    1. Commented 12 days ago

      Hi jabir!

      1. This is a native browser behavior when forms are submitted with a password field. So, I suppose one way would be to not use the type="password" on the input, but I wouldn't recommend that as prying eyes could easily grab someones credentials. There's a long discussion on StackOverflow of some attributes that may do the trick, though I'm not sure which are working as of today since browsers tend to change behaviors like this over time.

      2. Is this with forward navigation or using the browser's back button? If it is with the browser's back button, I don't think there is much you can do as that restores the saved state of the page in the browser's navigation history. The behavior you see there is going to match any multi-page application. If it is forward navigation, then that shouldn't be happening and there is likely a state update issue somewhere in your code. Happy to help dig in if it is a forward navigation issue and you're able to share code.

      0

      Please sign in or sign up for free to reply

      1. Commented 12 days ago

        Hi Tom,

        Thanks for the detailed response!
        1. I was specifically referring to cases where a user enters an incorrect email or password. Typically, browsers don't display a popup for such scenarios. I initially thought this might be due to the POST login endpoint returning a non-error HTTP response code (302). However, I checked the Laravel Forge site, which uses Inertia, and noticed that no popup appears when incorrect credentials are submitted even though the response code is 302.
        2. I was navigating using the browser's back button. I suppose I'll just have to live with it.

        1

        Please sign in or sign up for free to reply

        1. Commented 11 days ago

          Anytime!!

          I'm fairly certain the browser displays the popup before the response of the request is actually received, at least that is the behavior I've noticed in the past with Firefox (the browser I use).

          I, unfortunately, don't think or know of a way where is a way to enable/disable depending on success. I tested on Laravel Forge's site and still got the popup with invalid credentials (screenshot below). I can't say for certain it is impossible to do, but to the best of my knowledge I'm not aware of a way. Sorry, I know I haven't been much of a help here.

          0

          Please sign in or sign up for free to reply

          1. Commented 9 days ago

            No worries, Thanks a lot Tom.

            1

            Please sign in or sign up for free to reply

            1. Commented 7 days ago

              Anytime, jabir!

              0

              Please sign in or sign up for free to reply