[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
This commit is contained in:
+12
-60
@@ -45,11 +45,7 @@ class User(ormar.Model):
|
|||||||
totp_secret: str = ormar.String(max_length=32, min_length=32, nullable=True, default=None)
|
totp_secret: str = ormar.String(max_length=32, min_length=32, nullable=True, default=None)
|
||||||
storage_used: int = ormar.BigInteger(nullable=False, default=0, minimum=0)
|
storage_used: int = ormar.BigInteger(nullable=False, default=0, minimum=0)
|
||||||
|
|
||||||
ormar_config = ormar.OrmarConfig(
|
ormar_config = ormar.OrmarConfig(database=database, metadata=metadata, tablename="users")
|
||||||
database=database,
|
|
||||||
metadata=metadata,
|
|
||||||
tablename="users"
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
class FidoCredentials(ormar.Model):
|
class FidoCredentials(ormar.Model):
|
||||||
@@ -59,22 +55,14 @@ class FidoCredentials(ormar.Model):
|
|||||||
sign_count: int = ormar.Integer()
|
sign_count: int = ormar.Integer()
|
||||||
user: Optional[User] = ormar.ForeignKey(User, ondelete=ReferentialAction.CASCADE)
|
user: Optional[User] = ormar.ForeignKey(User, ondelete=ReferentialAction.CASCADE)
|
||||||
|
|
||||||
ormar_config = ormar.OrmarConfig(
|
ormar_config = ormar.OrmarConfig(database=database, metadata=metadata, tablename="fido_credentials")
|
||||||
database=database,
|
|
||||||
metadata=metadata,
|
|
||||||
tablename="fido_credentials"
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
class ApiKey(ormar.Model):
|
class ApiKey(ormar.Model):
|
||||||
key: str = ormar.String(max_length=48, min_length=48, primary_key=True)
|
key: str = ormar.String(max_length=48, min_length=48, primary_key=True)
|
||||||
user: Optional[User] = ormar.ForeignKey(User, ondelete=ReferentialAction.CASCADE)
|
user: Optional[User] = ormar.ForeignKey(User, ondelete=ReferentialAction.CASCADE)
|
||||||
|
|
||||||
ormar_config = ormar.OrmarConfig(
|
ormar_config = ormar.OrmarConfig(database=database, metadata=metadata, tablename="api_keys")
|
||||||
database=database,
|
|
||||||
metadata=metadata,
|
|
||||||
tablename="api_keys"
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
class UserSession(ormar.Model):
|
class UserSession(ormar.Model):
|
||||||
@@ -90,11 +78,7 @@ class UserSession(ormar.Model):
|
|||||||
user_agent: str = ormar.String(max_length=255, nullable=True)
|
user_agent: str = ormar.String(max_length=255, nullable=True)
|
||||||
last_seen: datetime = ormar.DateTime(default=datetime.now())
|
last_seen: datetime = ormar.DateTime(default=datetime.now())
|
||||||
|
|
||||||
ormar_config = ormar.OrmarConfig(
|
ormar_config = ormar.OrmarConfig(database=database, metadata=metadata, tablename="user_sessions")
|
||||||
database=database,
|
|
||||||
metadata=metadata,
|
|
||||||
tablename="user_sessions"
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
class ABCDQuizAnswer(BaseModel):
|
class ABCDQuizAnswer(BaseModel):
|
||||||
@@ -187,21 +171,13 @@ class Quiz(ormar.Model):
|
|||||||
views: int = ormar.Integer(nullable=False, default=0, server_default="0")
|
views: int = ormar.Integer(nullable=False, default=0, server_default="0")
|
||||||
mod_rating: int | None = ormar.SmallInteger(nullable=True)
|
mod_rating: int | None = ormar.SmallInteger(nullable=True)
|
||||||
|
|
||||||
ormar_config = ormar.OrmarConfig(
|
ormar_config = ormar.OrmarConfig(tablename="quiz", metadata=metadata, database=database)
|
||||||
tablename = "quiz",
|
|
||||||
metadata = metadata,
|
|
||||||
database = database
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
class InstanceData(ormar.Model):
|
class InstanceData(ormar.Model):
|
||||||
instance_id: uuid.UUID = ormar.UUID(primary_key=True, default=uuid.uuid4(), nullable=False, unique=True)
|
instance_id: uuid.UUID = ormar.UUID(primary_key=True, default=uuid.uuid4(), nullable=False, unique=True)
|
||||||
|
|
||||||
ormar_config = ormar.OrmarConfig(
|
ormar_config = ormar.OrmarConfig(tablename="instance_data", metadata=metadata, database=database)
|
||||||
tablename = "instance_data",
|
|
||||||
metadata = metadata,
|
|
||||||
database = database
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
class Token(BaseModel):
|
class Token(BaseModel):
|
||||||
@@ -310,11 +286,7 @@ class GameResults(ormar.Model):
|
|||||||
description: str = ormar.Text(nullable=False)
|
description: str = ormar.Text(nullable=False)
|
||||||
questions: Json[list[QuizQuestion]] = ormar.JSON(nullable=False)
|
questions: Json[list[QuizQuestion]] = ormar.JSON(nullable=False)
|
||||||
|
|
||||||
ormar_config = ormar.OrmarConfig(
|
ormar_config = ormar.OrmarConfig(database=database, metadata=metadata, tablename="game_results")
|
||||||
database=database,
|
|
||||||
metadata=metadata,
|
|
||||||
tablename="game_results"
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
class QuizTivityInput(BaseModel):
|
class QuizTivityInput(BaseModel):
|
||||||
@@ -329,11 +301,7 @@ class QuizTivity(ormar.Model):
|
|||||||
user: User | None = ormar.ForeignKey(User, ondelete=ReferentialAction.CASCADE)
|
user: User | None = ormar.ForeignKey(User, ondelete=ReferentialAction.CASCADE)
|
||||||
pages: list[QuizTivityPage] = ormar.JSON(nullable=False)
|
pages: list[QuizTivityPage] = ormar.JSON(nullable=False)
|
||||||
|
|
||||||
ormar_config = ormar.OrmarConfig(
|
ormar_config = ormar.OrmarConfig(tablename="quiztivitys", metadata=metadata, database=database)
|
||||||
tablename = "quiztivitys",
|
|
||||||
metadata = metadata,
|
|
||||||
database = database
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
class QuizTivityShare(ormar.Model):
|
class QuizTivityShare(ormar.Model):
|
||||||
@@ -343,11 +311,7 @@ class QuizTivityShare(ormar.Model):
|
|||||||
quiztivity: QuizTivity | None = ormar.ForeignKey(QuizTivity, ondelete=ReferentialAction.CASCADE)
|
quiztivity: QuizTivity | None = ormar.ForeignKey(QuizTivity, ondelete=ReferentialAction.CASCADE)
|
||||||
user: User | None = ormar.ForeignKey(User, ondelete=ReferentialAction.CASCADE)
|
user: User | None = ormar.ForeignKey(User, ondelete=ReferentialAction.CASCADE)
|
||||||
|
|
||||||
ormar_config = ormar.OrmarConfig(
|
ormar_config = ormar.OrmarConfig(database=database, metadata=metadata, tablename="quiztivityshares")
|
||||||
database=database,
|
|
||||||
metadata=metadata,
|
|
||||||
tablename="quiztivityshares"
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
class OnlyId(BaseModel):
|
class OnlyId(BaseModel):
|
||||||
@@ -392,11 +356,7 @@ class StorageItem(ormar.Model):
|
|||||||
server: str | None = ormar.Text(default=None, nullable=True)
|
server: str | None = ormar.Text(default=None, nullable=True)
|
||||||
imported: bool = ormar.Boolean(default=False, nullable=True)
|
imported: bool = ormar.Boolean(default=False, nullable=True)
|
||||||
|
|
||||||
ormar_config = ormar.OrmarConfig(
|
ormar_config = ormar.OrmarConfig(database=database, metadata=metadata, tablename="storage_items")
|
||||||
database=database,
|
|
||||||
metadata=metadata,
|
|
||||||
tablename="storage_items"
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
class PublicStorageItem(BaseModel):
|
class PublicStorageItem(BaseModel):
|
||||||
@@ -480,11 +440,7 @@ class Controller(ormar.Model):
|
|||||||
os_version: str | None = ormar.Text(nullable=True)
|
os_version: str | None = ormar.Text(nullable=True)
|
||||||
wanted_os_version: str = ormar.Text(nullable=True, default=None)
|
wanted_os_version: str = ormar.Text(nullable=True, default=None)
|
||||||
|
|
||||||
ormar_config = ormar.OrmarConfig(
|
ormar_config = ormar.OrmarConfig(tablename="controller", metadata=metadata, database=database)
|
||||||
tablename = "controller",
|
|
||||||
metadata = metadata,
|
|
||||||
database = database
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
class Rating(ormar.Model):
|
class Rating(ormar.Model):
|
||||||
@@ -494,8 +450,4 @@ class Rating(ormar.Model):
|
|||||||
created_at: datetime = ormar.DateTime(nullable=False, server_default=func.now())
|
created_at: datetime = ormar.DateTime(nullable=False, server_default=func.now())
|
||||||
quiz: uuid.UUID | Quiz = ormar.ForeignKey(Quiz)
|
quiz: uuid.UUID | Quiz = ormar.ForeignKey(Quiz)
|
||||||
|
|
||||||
ormar_config = ormar.OrmarConfig(
|
ormar_config = ormar.OrmarConfig(database=database, metadata=metadata, tablename="rating")
|
||||||
database=database,
|
|
||||||
metadata=metadata,
|
|
||||||
tablename="rating"
|
|
||||||
)
|
|
||||||
|
|||||||
@@ -102,19 +102,19 @@ def verify_webauthn(data, fidocredentialss: list[FidoCredentials], login_session
|
|||||||
@router.post("/start")
|
@router.post("/start")
|
||||||
async def start_login(data: StartLoginInput):
|
async def start_login(data: StartLoginInput):
|
||||||
user = (
|
user = (
|
||||||
#TODO Find out why the fidocredentialls call fails
|
# TODO Find out why the fidocredentialls call fails
|
||||||
await User.objects.select_related("fidocredentialss")
|
await User.objects.select_related("fidocredentialss")
|
||||||
.filter((User.email == data.email) | (User.username == data.email))
|
.filter((User.email == data.email) | (User.username == data.email))
|
||||||
.get_or_none()
|
.get_or_none()
|
||||||
# await User.objects.filter((User.email == data.email) | (User.username == data.email))
|
# await User.objects.filter((User.email == data.email) | (User.username == data.email))
|
||||||
# .get_or_none()
|
# .get_or_none()
|
||||||
)
|
)
|
||||||
print("User.objects.filter call completed...")
|
print("User.objects.filter call completed...")
|
||||||
step_1: set[StartLoginResponseTypes] = set()
|
step_1: set[StartLoginResponseTypes] = set()
|
||||||
step_2: set[StartLoginResponseTypes] = set()
|
step_2: set[StartLoginResponseTypes] = set()
|
||||||
webauthn_data = None
|
webauthn_data = None
|
||||||
webauthn_challenge = None
|
webauthn_challenge = None
|
||||||
print("\"webauthn_challenge = None\" call completed...")
|
print('"webauthn_challenge = None" call completed...')
|
||||||
print("user.verified: " + str(user.verified))
|
print("user.verified: " + str(user.verified))
|
||||||
if user is None or not user.verified:
|
if user is None or not user.verified:
|
||||||
step_1.add(StartLoginResponseTypes.PASSWORD)
|
step_1.add(StartLoginResponseTypes.PASSWORD)
|
||||||
@@ -122,7 +122,7 @@ async def start_login(data: StartLoginInput):
|
|||||||
print("Okay. User is not None or unverified...")
|
print("Okay. User is not None or unverified...")
|
||||||
if user.password is not None:
|
if user.password is not None:
|
||||||
step_1.add(StartLoginResponseTypes.PASSWORD)
|
step_1.add(StartLoginResponseTypes.PASSWORD)
|
||||||
''' TODO Find out why fidocredentialss is causing problems
|
""" TODO Find out why fidocredentialss is causing problems
|
||||||
if len(user.fidocredentialss) > 0:
|
if len(user.fidocredentialss) > 0:
|
||||||
if user.require_password is True:
|
if user.require_password is True:
|
||||||
step_2.add(StartLoginResponseTypes.PASSKEY)
|
step_2.add(StartLoginResponseTypes.PASSKEY)
|
||||||
@@ -137,7 +137,7 @@ async def start_login(data: StartLoginInput):
|
|||||||
)
|
)
|
||||||
webauthn_challenge = base64.b64encode(webauthn_data.challenge).decode("utf-8")
|
webauthn_challenge = base64.b64encode(webauthn_data.challenge).decode("utf-8")
|
||||||
webauthn_data = options_to_json(webauthn_data)
|
webauthn_data = options_to_json(webauthn_data)
|
||||||
'''
|
"""
|
||||||
print("Moving past commented code, the long string one...")
|
print("Moving past commented code, the long string one...")
|
||||||
if user.totp_secret is not None:
|
if user.totp_secret is not None:
|
||||||
if user.require_password:
|
if user.require_password:
|
||||||
@@ -180,7 +180,7 @@ async def step_1_endpoint(session_id: str, data: StepInput, request: Request, re
|
|||||||
else:
|
else:
|
||||||
print("unknown step")
|
print("unknown step")
|
||||||
raise HTTPException(401)
|
raise HTTPException(401)
|
||||||
#TODO fidocredentials bug fix user = await User.objects.select_related("fidocredentialss").get_or_none(id=uuid.UUID(login_session.user_id))
|
# TODO fidocredentials bug fix user = await User.objects.select_related("fidocredentialss").get_or_none(id=uuid.UUID(login_session.user_id))
|
||||||
user = await User.objects.get_or_none(id=uuid.UUID(login_session.user_id))
|
user = await User.objects.get_or_none(id=uuid.UUID(login_session.user_id))
|
||||||
if data.auth_type == StartLoginResponseTypes.PASSWORD:
|
if data.auth_type == StartLoginResponseTypes.PASSWORD:
|
||||||
if verify_password(data.data, user.password):
|
if verify_password(data.data, user.password):
|
||||||
|
|||||||
Generated
+2548
-877
File diff suppressed because it is too large
Load Diff
@@ -31,17 +31,15 @@ const config = {
|
|||||||
},
|
},
|
||||||
build: {
|
build: {
|
||||||
sourcemap: true
|
sourcemap: true
|
||||||
},
|
}
|
||||||
|
|
||||||
/* Trying
|
/* Trying
|
||||||
|
|
||||||
ssr: {
|
ssr: {
|
||||||
noExternal: ['@ckeditor/*'],
|
noExternal: ['@ckeditor/*'],
|
||||||
}
|
}
|
||||||
|
|
||||||
end trying*/
|
end trying*/
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export default config;
|
export default config;
|
||||||
|
|||||||
Reference in New Issue
Block a user