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

auth.attempt() returns None when once=True #836

Open
ReS4 opened this issue Nov 2, 2024 · 0 comments
Open

auth.attempt() returns None when once=True #836

ReS4 opened this issue Nov 2, 2024 · 0 comments
Labels

Comments

@ReS4
Copy link

ReS4 commented Nov 2, 2024

Describe the bug

The function auth.attempt() should return the user model when the parameter once is set to True, but currently, it returns None instead.

Expected behaviour

auth.attempt() must return the user model when the credentials are valid whether the once parameter is set or not.

Steps to reproduce the bug

user = auth.attempt(request.input("email"), request.input("password"), once=True)
if user: # user is always None
    print(user.id)

Masonite Version

4.20.0

Anything else ?

the Default WebGuard's attempt method can be rewritten to something like this:

masonite.authentication.guards.WebGuard.py

def attempt(self, username, password):
    attempt = self.options.get("model")().attempt(username, password)
    if attempt and not self.options.get("once"):
        self.application.make("response").cookie("token", attempt.remember_token)
        self.application.make("request").set_user(attempt)
    return attempt # change this line
@ReS4 ReS4 added the bug label Nov 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant