1.0.0 • Published 6 years ago

@alu0100966589/auth v1.0.0

Weekly downloads
-
License
MIT
Repository
-
Last release
6 years ago

Auth

This module was made for education purpose. The goal was to do a basic authorization middleware to know how it works.

About this module

This module exports a function that returns an express router to use as middleware. It defines the routes '/login', '/register' via GET and POST methods, '/logout' via the GET method only. And '/content' via the GET method and this is the route that will be protected and users must be logged in before accessing this route, otherwise a 401 message will be sent with an unauthorized view.

Student

  • Carlos Domínguez García (alu0100966589@ull.edu.es)

API

The function that exports the module needs an object. The properties of that object are the following:

  • passwordFile: location of the file to store the users credentials.

  • pathToProtect: the files that will be accessible only when users are logged in.

  • registerView: view containing the form to register. It will be served at '/register' via the HTTP GET method.

  • successRegisterView: view with the message to render when the user registers successfully.

  • errorRegisterView: view to render when there is an error in the registration.

  • loginView: view containing the form to log in. It will be served at '/login' via the HTTP GET method.

  • successLoginView: view with the message to render when the user logs in successfully.

  • errorLoginView: view to render when there is an error in the login.

  • logoutView: view to render when they log out.

  • unauthorizedView: view to render when a user tries to access '/content' without being logged in

1.0.0

6 years ago