mirror of
https://gitlab.archlinux.org/archlinux/aurweb.git
synced 2025-02-03 10:43:03 +01:00
add authenticated User LangPreference tracking
+ Use User.LangPreference when there is no set AURSID if request.user.is_authenticated is true. + Updated post /language to update LangPreference when request.user.is_authenticated. + Restore language during test where we change it. + Added the user attribute to aurweb.testing.requests.Request. Signed-off-by: Kevin Morris <kevr@0cost.org>
This commit is contained in:
parent
a33d076d8b
commit
9fdbe3f775
5 changed files with 59 additions and 14 deletions
|
@ -1,8 +1,27 @@
|
|||
import aurweb.config
|
||||
|
||||
|
||||
class User:
|
||||
""" A fake User model. """
|
||||
# Fake columns.
|
||||
LangPreference = aurweb.config.get("options", "default_lang")
|
||||
|
||||
# A fake authenticated flag.
|
||||
authenticated = False
|
||||
|
||||
def is_authenticated(self):
|
||||
return self.authenticated
|
||||
|
||||
|
||||
class Client:
|
||||
""" A fake FastAPI Request.client object. """
|
||||
# A fake host.
|
||||
host = "127.0.0.1"
|
||||
|
||||
|
||||
class Request:
|
||||
""" A fake Request object which mimics a FastAPI Request for tests. """
|
||||
client = Client()
|
||||
cookies = dict()
|
||||
headers = dict()
|
||||
user = User()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue