This module was made to implement an authorization type middleware that would let you navigate through different paths. Therefore exports a function that returns an middleware used for that purpose.
This module defines the following:
- Route for accesing the content of the page through the /content path using the GET method, only when the user is logged in the current session
- Route for login into the website through the /login route using the GET/POST method, to be able to visualize the content of the page you need to be logged in
- Route for registering into the website through the /register route using the GET/POST method, to be able to login into the website you need a valid account.
The function that exports the module needs an data type object,this object having the following attributes:
-
passwordFile
: this option declares the file/path of the path were the credentials will be stored -
pathToProtect
: this option declares the route/path to the content of the website that only the logged user can see. -
registerView
: this option represents the view of the register form that can be accesed through the /register path. -
successRegisterView
: this option represents the succesfully made register view that is rendered when the account is succesfully created. -
errorRegisterView
: this option represents an error view that is rendered when an error ocurrs while creating the account. -
loginView
: this option represents the view of the login form that can be accesed through the /login path. -
successLoginView
: this option represents the succesfully made login view that is rendered when the login is succesfully made. -
errorLoginView
: this option represents an error view that is rendered when an error ocurrs while loging into the account. -
logoutView
: this option represents the view that the user will get once they log out of their account -
unauthorizedView
: this option represents the view that the user will get if they access the content(/content path) without being logged in.