fix: add dedicated authenticate_user() method for auth view
in case subclass needs to tweak that behavior
This commit is contained in:
parent
204548e4f2
commit
b410b5aa02
1 changed files with 10 additions and 4 deletions
|
|
@ -2,7 +2,7 @@
|
||||||
################################################################################
|
################################################################################
|
||||||
#
|
#
|
||||||
# wuttaweb -- Web App for Wutta Framework
|
# wuttaweb -- Web App for Wutta Framework
|
||||||
# Copyright © 2024-2025 Lance Edgar
|
# Copyright © 2024-2026 Lance Edgar
|
||||||
#
|
#
|
||||||
# This file is part of Wutta Framework.
|
# This file is part of Wutta Framework.
|
||||||
#
|
#
|
||||||
|
|
@ -49,7 +49,6 @@ class AuthView(View):
|
||||||
"""
|
"""
|
||||||
model = self.app.model
|
model = self.app.model
|
||||||
session = session or Session()
|
session = session or Session()
|
||||||
auth = self.app.get_auth_handler()
|
|
||||||
|
|
||||||
# nb. redirect to /setup if no users exist
|
# nb. redirect to /setup if no users exist
|
||||||
user = session.query(model.User).first()
|
user = session.query(model.User).first()
|
||||||
|
|
@ -79,8 +78,9 @@ class AuthView(View):
|
||||||
if data:
|
if data:
|
||||||
|
|
||||||
# truly validate user credentials
|
# truly validate user credentials
|
||||||
user = auth.authenticate_user(session, data["username"], data["password"])
|
if user := self.authenticate_user(
|
||||||
if user:
|
session, data["username"], data["password"]
|
||||||
|
):
|
||||||
|
|
||||||
# okay now they're truly logged in
|
# okay now they're truly logged in
|
||||||
headers = login_user(self.request, user)
|
headers = login_user(self.request, user)
|
||||||
|
|
@ -95,6 +95,12 @@ class AuthView(View):
|
||||||
# 'referrer': referrer,
|
# 'referrer': referrer,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
def authenticate_user(
|
||||||
|
self, session, username, password
|
||||||
|
): # pylint: disable=missing-function-docstring
|
||||||
|
auth = self.app.get_auth_handler()
|
||||||
|
return auth.authenticate_user(session, username, password)
|
||||||
|
|
||||||
def login_make_schema(self): # pylint: disable=empty-docstring
|
def login_make_schema(self): # pylint: disable=empty-docstring
|
||||||
""" """
|
""" """
|
||||||
schema = colander.Schema()
|
schema = colander.Schema()
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue