Form Setup
We took a glance at using forms and actions together in Chapter 4. And while covering RequestEvent
in the previous chapter, we began creating the code necessary to authenticate a user in our application with cookies. However, in that example, we never gave the user a means to provide a username or password. We also never created the cookie in the application. Instead, we opted to manually create one using the browser’s developer tools. It’s time we bring the whole thing together. Since we’ve covered the logic related to load()
, as well as the details surrounding RequestEvent
, we can continue building off of our previous example. A good place to start would be the login form itself. After all, we can’t log a user in without giving them a place to do so.
But before we create the form, let’s go ahead and add a link to the login page in our navigation:
src/lib/Nav.svelte
<nav> <ul> <...