Summary
We started this chapter by building a simple <form>
element that accepts a username and password. On the same page component, we relayed the status of the authentication attempt back to the user. After this, we created a form action that looked up the username and compared the provided password with a hashed value. If successful, we logged the user in by setting a cookie on their device. If unsuccessful, we informed the user that their attempt had failed. We also briefly discussed some security best practices surrounding authenticating users with our application. We then examined how experiences with <form>
elements can be improved by using enhance
and snapshots. Having done all of this, we can be confident in any forms we implement in future SvelteKit projects.
With everything we’ve covered up until this point, you should be able to put together a basic website or application. In the next chapter, we’ll cover more advanced functionality that can...