app/Usermodel but you can change this in the
config/auth.pyconfiguration file which you can use to set the authentication behavior of your Masonite project. If you wish to change the authentication model, to a
Companymodel for example, feel free to do in this configuration file.
False, the token will simply continue to refill the user model and set a new token all without touching the database.
app/Usermodel which out of the box comes with a
__auth__class attribute. This attribute should be set to the column that you want to authenticate with when a user logs in.
app/Usermodel will default to the
name, you can do so here. This will lead your model to look like:
__auth__attribute as a list of columns:
passwordcolumn to authenticate as the password. Some applications may have this changed. Your specific application may be authenticating with a
tokencolumn for example.
__password__attribute to the column name:
Authclass that ships with Masonite. This is simply a class that is used to authenticate models with a
bcryptand return the model. If it is not found or the password does not match, it will return
__auth__class attribute. This will look something like:
craft authcommand, just run the server and navigate to
http://localhost:8000/loginand you will now have a login, registration and dashboard. Pretty cool, huh?
LoadUserMiddlewaremiddleware that will load the user into the request if they are authenticated. Masonite uses the
tokencookie in order to retrieve the user using the
remember_tokencolumn in the table.
LoadUserMiddlewaremiddleware you can retrieve the current user using:
Falseif the user is not authenticated. This will look like:
register()method on the
login. If you wish to redirect the user to another route or to a different URI, you can edit the middleware in
Authclass. This looks like:
VerifyEmailMiddlewareclass to redirect an unverified user.