Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

What is the point of these middlewares? #310

Closed
ibraheemdev opened this issue Aug 30, 2020 · 2 comments
Closed

What is the point of these middlewares? #310

ibraheemdev opened this issue Aug 30, 2020 · 2 comments

Comments

@ibraheemdev
Copy link
Contributor

ibraheemdev commented Aug 30, 2020

There are two middlewares that I don't understand fully:

lock.Middleware: Rejects requests from locked users
confirm.Middleware: Ensures users are confirmed or rejects request

These middlewares are meant to be put on authenticated routes (routes where the user must have an account to access).
However, rejecting users from locked or unconfirmed users is already taken care of by the auth events provided by the respective modules Init function:

c.Events.Before(authboss.EventAuth, c.PreventAuth) confirm.Middleware
PreventAuth stops the EventAuth from succeeding when a user is not confirmed Middleware ensures that a user is confirmed, or else it will intercept the request and send them to the confirm page
l.Events.Before(authboss.EventAuth, l.BeforeAuth) lock.Middleware
BeforeAuth ensures the account is not locked. Middleware ensures that a user is not locked, or else it will intercept the request and send them to the configured LockNotOK page

There seems to be complete overlap between the middlewares and the before auth events. If a route is already protected by authboss.Middleware, are the lock and confirm middlewares even needed? What is the use case for them?

@aarondl
Copy link
Member

aarondl commented Sep 22, 2020

The only thing these do is allow you to protect non-login endpoints from unconfirmed or locked users. If you don't use this, a locked user that gets a session (or a user who becomes locked during their session for other reasons) can still access pages as an example.

@ibraheemdev
Copy link
Contributor Author

Oh, I get it. Because the auth events only protect on login, and once the session is created a locked user can still access pages

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants