[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
This commit is contained in:
+15
-15
@@ -35,21 +35,21 @@ class Settings(BaseSettings):
|
||||
db_url: str | PostgresDsn = "postgresql://postgres:mysecretpassword@localhost:5432/classquiz"
|
||||
hcaptcha_key: str | None = None
|
||||
recaptcha_key: str | None = None
|
||||
mail_address: str
|
||||
mail_password: str
|
||||
mail_username: str
|
||||
mail_server: str
|
||||
mail_port: int
|
||||
secret_key: str
|
||||
mail_address: str
|
||||
mail_password: str
|
||||
mail_username: str
|
||||
mail_server: str
|
||||
mail_port: int
|
||||
secret_key: str
|
||||
access_token_expire_minutes: int = 30
|
||||
cache_expiry: int = 86400
|
||||
sentry_dsn: str | None = None
|
||||
sentry_dsn: str | None = None
|
||||
meilisearch_url: str = "http://127.0.0.1:7700"
|
||||
meilisearch_index: str = "classquiz"
|
||||
google_client_id: str | None = None
|
||||
google_client_secret: str | None = None
|
||||
github_client_id: str | None = None
|
||||
github_client_secret: str | None = None
|
||||
google_client_id: str | None = None
|
||||
google_client_secret: str | None = None
|
||||
github_client_id: str | None = None
|
||||
github_client_secret: str | None = None
|
||||
custom_openid_provider: CustomOpenIDProvider | None = None
|
||||
telemetry_enabled: bool = True
|
||||
free_storage_limit: int = 1074000000
|
||||
@@ -61,13 +61,13 @@ class Settings(BaseSettings):
|
||||
storage_backend: str | None = "local"
|
||||
|
||||
# if storage_backend == "local":
|
||||
storage_path: str | None = None
|
||||
storage_path: str | None = None
|
||||
|
||||
# if storage_backend == "s3":
|
||||
s3_access_key: str | None = None
|
||||
s3_secret_key: str | None = None
|
||||
s3_access_key: str | None = None
|
||||
s3_secret_key: str | None = None
|
||||
s3_bucket_name: str = "classquiz"
|
||||
s3_base_url: str | None = None
|
||||
s3_base_url: str | None = None
|
||||
|
||||
class Config:
|
||||
env_file = ".env"
|
||||
|
||||
+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)
|
||||
storage_used: int = ormar.BigInteger(nullable=False, default=0, minimum=0)
|
||||
|
||||
ormar_config = ormar.OrmarConfig(
|
||||
database=database,
|
||||
metadata=metadata,
|
||||
tablename="users"
|
||||
)
|
||||
ormar_config = ormar.OrmarConfig(database=database, metadata=metadata, tablename="users")
|
||||
|
||||
|
||||
class FidoCredentials(ormar.Model):
|
||||
@@ -59,22 +55,14 @@ class FidoCredentials(ormar.Model):
|
||||
sign_count: int = ormar.Integer()
|
||||
user: Optional[User] = ormar.ForeignKey(User, ondelete=ReferentialAction.CASCADE)
|
||||
|
||||
ormar_config = ormar.OrmarConfig(
|
||||
database=database,
|
||||
metadata=metadata,
|
||||
tablename="fido_credentials"
|
||||
)
|
||||
ormar_config = ormar.OrmarConfig(database=database, metadata=metadata, tablename="fido_credentials")
|
||||
|
||||
|
||||
class ApiKey(ormar.Model):
|
||||
key: str = ormar.String(max_length=48, min_length=48, primary_key=True)
|
||||
user: Optional[User] = ormar.ForeignKey(User, ondelete=ReferentialAction.CASCADE)
|
||||
|
||||
ormar_config = ormar.OrmarConfig(
|
||||
database=database,
|
||||
metadata=metadata,
|
||||
tablename="api_keys"
|
||||
)
|
||||
ormar_config = ormar.OrmarConfig(database=database, metadata=metadata, tablename="api_keys")
|
||||
|
||||
|
||||
class UserSession(ormar.Model):
|
||||
@@ -90,11 +78,7 @@ class UserSession(ormar.Model):
|
||||
user_agent: str = ormar.String(max_length=255, nullable=True)
|
||||
last_seen: datetime = ormar.DateTime(default=datetime.now())
|
||||
|
||||
ormar_config = ormar.OrmarConfig(
|
||||
database=database,
|
||||
metadata=metadata,
|
||||
tablename="user_sessions"
|
||||
)
|
||||
ormar_config = ormar.OrmarConfig(database=database, metadata=metadata, tablename="user_sessions")
|
||||
|
||||
|
||||
class ABCDQuizAnswer(BaseModel):
|
||||
@@ -187,21 +171,13 @@ class Quiz(ormar.Model):
|
||||
views: int = ormar.Integer(nullable=False, default=0, server_default="0")
|
||||
mod_rating: int | None = ormar.SmallInteger(nullable=True)
|
||||
|
||||
ormar_config = ormar.OrmarConfig(
|
||||
tablename = "quiz",
|
||||
metadata = metadata,
|
||||
database = database
|
||||
)
|
||||
ormar_config = ormar.OrmarConfig(tablename="quiz", metadata=metadata, database=database)
|
||||
|
||||
|
||||
class InstanceData(ormar.Model):
|
||||
instance_id: uuid.UUID = ormar.UUID(primary_key=True, default=uuid.uuid4(), nullable=False, unique=True)
|
||||
|
||||
ormar_config = ormar.OrmarConfig(
|
||||
tablename = "instance_data",
|
||||
metadata = metadata,
|
||||
database = database
|
||||
)
|
||||
ormar_config = ormar.OrmarConfig(tablename="instance_data", metadata=metadata, database=database)
|
||||
|
||||
|
||||
class Token(BaseModel):
|
||||
@@ -310,11 +286,7 @@ class GameResults(ormar.Model):
|
||||
description: str = ormar.Text(nullable=False)
|
||||
questions: Json[list[QuizQuestion]] = ormar.JSON(nullable=False)
|
||||
|
||||
ormar_config = ormar.OrmarConfig(
|
||||
database=database,
|
||||
metadata=metadata,
|
||||
tablename="game_results"
|
||||
)
|
||||
ormar_config = ormar.OrmarConfig(database=database, metadata=metadata, tablename="game_results")
|
||||
|
||||
|
||||
class QuizTivityInput(BaseModel):
|
||||
@@ -329,11 +301,7 @@ class QuizTivity(ormar.Model):
|
||||
user: User | None = ormar.ForeignKey(User, ondelete=ReferentialAction.CASCADE)
|
||||
pages: list[QuizTivityPage] = ormar.JSON(nullable=False)
|
||||
|
||||
ormar_config = ormar.OrmarConfig(
|
||||
tablename = "quiztivitys",
|
||||
metadata = metadata,
|
||||
database = database
|
||||
)
|
||||
ormar_config = ormar.OrmarConfig(tablename="quiztivitys", metadata=metadata, database=database)
|
||||
|
||||
|
||||
class QuizTivityShare(ormar.Model):
|
||||
@@ -343,11 +311,7 @@ class QuizTivityShare(ormar.Model):
|
||||
quiztivity: QuizTivity | None = ormar.ForeignKey(QuizTivity, ondelete=ReferentialAction.CASCADE)
|
||||
user: User | None = ormar.ForeignKey(User, ondelete=ReferentialAction.CASCADE)
|
||||
|
||||
ormar_config = ormar.OrmarConfig(
|
||||
database=database,
|
||||
metadata=metadata,
|
||||
tablename="quiztivityshares"
|
||||
)
|
||||
ormar_config = ormar.OrmarConfig(database=database, metadata=metadata, tablename="quiztivityshares")
|
||||
|
||||
|
||||
class OnlyId(BaseModel):
|
||||
@@ -392,11 +356,7 @@ class StorageItem(ormar.Model):
|
||||
server: str | None = ormar.Text(default=None, nullable=True)
|
||||
imported: bool = ormar.Boolean(default=False, nullable=True)
|
||||
|
||||
ormar_config = ormar.OrmarConfig(
|
||||
database=database,
|
||||
metadata=metadata,
|
||||
tablename="storage_items"
|
||||
)
|
||||
ormar_config = ormar.OrmarConfig(database=database, metadata=metadata, tablename="storage_items")
|
||||
|
||||
|
||||
class PublicStorageItem(BaseModel):
|
||||
@@ -480,11 +440,7 @@ class Controller(ormar.Model):
|
||||
os_version: str | None = ormar.Text(nullable=True)
|
||||
wanted_os_version: str = ormar.Text(nullable=True, default=None)
|
||||
|
||||
ormar_config = ormar.OrmarConfig(
|
||||
tablename = "controller",
|
||||
metadata = metadata,
|
||||
database = database
|
||||
)
|
||||
ormar_config = ormar.OrmarConfig(tablename="controller", metadata=metadata, database=database)
|
||||
|
||||
|
||||
class Rating(ormar.Model):
|
||||
@@ -494,8 +450,4 @@ class Rating(ormar.Model):
|
||||
created_at: datetime = ormar.DateTime(nullable=False, server_default=func.now())
|
||||
quiz: uuid.UUID | Quiz = ormar.ForeignKey(Quiz)
|
||||
|
||||
ormar_config = ormar.OrmarConfig(
|
||||
database=database,
|
||||
metadata=metadata,
|
||||
tablename="rating"
|
||||
)
|
||||
ormar_config = ormar.OrmarConfig(database=database, metadata=metadata, tablename="rating")
|
||||
|
||||
@@ -102,19 +102,19 @@ def verify_webauthn(data, fidocredentialss: list[FidoCredentials], login_session
|
||||
@router.post("/start")
|
||||
async def start_login(data: StartLoginInput):
|
||||
user = (
|
||||
#TODO Find out why the fidocredentialls call fails
|
||||
# TODO Find out why the fidocredentialls call fails
|
||||
await User.objects.select_related("fidocredentialss")
|
||||
.filter((User.email == data.email) | (User.username == data.email))
|
||||
.get_or_none()
|
||||
# await User.objects.filter((User.email == data.email) | (User.username == data.email))
|
||||
# .get_or_none()
|
||||
# await User.objects.filter((User.email == data.email) | (User.username == data.email))
|
||||
# .get_or_none()
|
||||
)
|
||||
print("User.objects.filter call completed...")
|
||||
step_1: set[StartLoginResponseTypes] = set()
|
||||
step_2: set[StartLoginResponseTypes] = set()
|
||||
webauthn_data = None
|
||||
webauthn_challenge = None
|
||||
print("\"webauthn_challenge = None\" call completed...")
|
||||
print('"webauthn_challenge = None" call completed...')
|
||||
print("user.verified: " + str(user.verified))
|
||||
if user is None or not user.verified:
|
||||
step_1.add(StartLoginResponseTypes.PASSWORD)
|
||||
@@ -122,7 +122,7 @@ async def start_login(data: StartLoginInput):
|
||||
print("Okay. User is not None or unverified...")
|
||||
if user.password is not None:
|
||||
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 user.require_password is True:
|
||||
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_data = options_to_json(webauthn_data)
|
||||
'''
|
||||
"""
|
||||
print("Moving past commented code, the long string one...")
|
||||
if user.totp_secret is not None:
|
||||
if user.require_password:
|
||||
@@ -180,7 +180,7 @@ async def step_1_endpoint(session_id: str, data: StepInput, request: Request, re
|
||||
else:
|
||||
print("unknown step")
|
||||
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))
|
||||
if data.auth_type == StartLoginResponseTypes.PASSWORD:
|
||||
if verify_password(data.data, user.password):
|
||||
|
||||
Generated
+6415
-4744
File diff suppressed because it is too large
Load Diff
@@ -31,17 +31,15 @@ const config = {
|
||||
},
|
||||
build: {
|
||||
sourcemap: true
|
||||
},
|
||||
}
|
||||
|
||||
/* Trying
|
||||
/* Trying
|
||||
|
||||
ssr: {
|
||||
noExternal: ['@ckeditor/*'],
|
||||
}
|
||||
|
||||
end trying*/
|
||||
|
||||
|
||||
};
|
||||
|
||||
export default config;
|
||||
|
||||
Reference in New Issue
Block a user