Creating a user model
The first step in building our authentication system will be to create a database model representing an individual user account. We will store the user's login credentials, along with some additional information such as the user's display name, and their account creation timestamp. Our model will have the following fields:
email
(unique): store the user's email address and use that for authenticationpassword_hash
: instead of stringing each user's password as plaintext, we will hash the password using a one-way cryptographic hash functionname
: the user's name, so we can display it alongside their blog entriesslug
: A URL-friendly representation of the user's name, also uniqueactive
: Boolean flag indicating whether this account is active. Only active users will be able to log into the sitecreated_timestamp
: The time this user account was created
Tip
If there are other fields you think might be useful, feel free to make your own additions to...