[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"
|
db_url: str | PostgresDsn = "postgresql://postgres:mysecretpassword@localhost:5432/classquiz"
|
||||||
hcaptcha_key: str | None = None
|
hcaptcha_key: str | None = None
|
||||||
recaptcha_key: str | None = None
|
recaptcha_key: str | None = None
|
||||||
mail_address: str
|
mail_address: str
|
||||||
mail_password: str
|
mail_password: str
|
||||||
mail_username: str
|
mail_username: str
|
||||||
mail_server: str
|
mail_server: str
|
||||||
mail_port: int
|
mail_port: int
|
||||||
secret_key: str
|
secret_key: str
|
||||||
access_token_expire_minutes: int = 30
|
access_token_expire_minutes: int = 30
|
||||||
cache_expiry: int = 86400
|
cache_expiry: int = 86400
|
||||||
sentry_dsn: str | None = None
|
sentry_dsn: str | None = None
|
||||||
meilisearch_url: str = "http://127.0.0.1:7700"
|
meilisearch_url: str = "http://127.0.0.1:7700"
|
||||||
meilisearch_index: str = "classquiz"
|
meilisearch_index: str = "classquiz"
|
||||||
google_client_id: str | None = None
|
google_client_id: str | None = None
|
||||||
google_client_secret: str | None = None
|
google_client_secret: str | None = None
|
||||||
github_client_id: str | None = None
|
github_client_id: str | None = None
|
||||||
github_client_secret: str | None = None
|
github_client_secret: str | None = None
|
||||||
custom_openid_provider: CustomOpenIDProvider | None = None
|
custom_openid_provider: CustomOpenIDProvider | None = None
|
||||||
telemetry_enabled: bool = True
|
telemetry_enabled: bool = True
|
||||||
free_storage_limit: int = 1074000000
|
free_storage_limit: int = 1074000000
|
||||||
@@ -61,13 +61,13 @@ class Settings(BaseSettings):
|
|||||||
storage_backend: str | None = "local"
|
storage_backend: str | None = "local"
|
||||||
|
|
||||||
# if storage_backend == "local":
|
# if storage_backend == "local":
|
||||||
storage_path: str | None = None
|
storage_path: str | None = None
|
||||||
|
|
||||||
# if storage_backend == "s3":
|
# if storage_backend == "s3":
|
||||||
s3_access_key: str | None = None
|
s3_access_key: str | None = None
|
||||||
s3_secret_key: str | None = None
|
s3_secret_key: str | None = None
|
||||||
s3_bucket_name: str = "classquiz"
|
s3_bucket_name: str = "classquiz"
|
||||||
s3_base_url: str | None = None
|
s3_base_url: str | None = None
|
||||||
|
|
||||||
class Config:
|
class Config:
|
||||||
env_file = ".env"
|
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)
|
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
+6415
-4744
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;
|
||||||
|
|||||||
+7
-7
@@ -9,9 +9,9 @@ run_tests() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
stop() {
|
stop() {
|
||||||
$CONTAINER_BIN container stop classquiz_db
|
$CONTAINER_BIN container stop classquiz_db
|
||||||
$CONTAINER_BIN container stop test_redis
|
$CONTAINER_BIN container stop test_redis
|
||||||
$CONTAINER_BIN container stop test_meili
|
$CONTAINER_BIN container stop test_meili
|
||||||
}
|
}
|
||||||
|
|
||||||
init() {
|
init() {
|
||||||
@@ -19,21 +19,21 @@ init() {
|
|||||||
mkdir /tmp/storage
|
mkdir /tmp/storage
|
||||||
fi
|
fi
|
||||||
|
|
||||||
$CONTAINER_BIN volume exists classquiz_db_data
|
$CONTAINER_BIN volume exists classquiz_db_data
|
||||||
if [ ! $? ]; then
|
if [ ! $? ]; then
|
||||||
$CONTAINER_BIN volume create classquiz_db_data
|
$CONTAINER_BIN volume create classquiz_db_data
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#Check Linux distribution, which is necessary for using Redis
|
#Check Linux distribution, which is necessary for using Redis
|
||||||
SYSINFO=$(uname -rv)
|
SYSINFO=$(uname -rv)
|
||||||
CONTAINER_REDIS=""
|
CONTAINER_REDIS=""
|
||||||
if [[ ${SYSINFO} == *"Ubuntu"* ]]; then
|
if [[ ${SYSINFO} == *"Ubuntu"* ]]; then
|
||||||
CONTAINER_REDIS=redis:buster
|
CONTAINER_REDIS=redis:buster
|
||||||
elif [[ ${SYSINFO} == *"Alpine"* ]]; then
|
elif [[ ${SYSINFO} == *"Alpine"* ]]; then
|
||||||
CONTAINER_REDIS=redis:alpine
|
CONTAINER_REDIS=redis:alpine
|
||||||
else
|
else
|
||||||
echo "Warning. Defaulting to Alpine Redis. If Redis error follows, please add your Linux distribution. Then make this script addition your first Class Quiz contribution! We will appreciate it!"
|
echo "Warning. Defaulting to Alpine Redis. If Redis error follows, please add your Linux distribution. Then make this script addition your first Class Quiz contribution! We will appreciate it!"
|
||||||
CONTAINER_REDIS=redis:alpine
|
CONTAINER_REDIS=redis:alpine
|
||||||
fi
|
fi
|
||||||
|
|
||||||
$CONTAINER_BIN run --rm -d -p 6379:6379 --name test_redis $CONTAINER_REDIS
|
$CONTAINER_BIN run --rm -d -p 6379:6379 --name test_redis $CONTAINER_REDIS
|
||||||
|
|||||||
+1
-1
@@ -14,7 +14,7 @@ stop() {
|
|||||||
$CONTAINER_BIN container stop test_meili --time 2
|
$CONTAINER_BIN container stop test_meili --time 2
|
||||||
$CONTAINER_BIN rm classquiz_db --force
|
$CONTAINER_BIN rm classquiz_db --force
|
||||||
$CONTAINER_BIN rm test_redis --force
|
$CONTAINER_BIN rm test_redis --force
|
||||||
$CONTAINER_BIN rm test_meili --force
|
$CONTAINER_BIN rm test_meili --force
|
||||||
}
|
}
|
||||||
|
|
||||||
init() {
|
init() {
|
||||||
|
|||||||
Reference in New Issue
Block a user