diff --git a/src/pwncore/config.py b/src/pwncore/config.py index b0f11f5..b344140 100644 --- a/src/pwncore/config.py +++ b/src/pwncore/config.py @@ -36,7 +36,7 @@ "user_removed": 19, "user_already_in_team": 20, "user_not_in_team": 21, - "insufficient_coins": 22 + "insufficient_coins": 22, } @@ -64,5 +64,5 @@ class Config: jwt_secret="mysecret", jwt_valid_duration=12, # In hours msg_codes=msg_codes, - hint_penalty=10 + hint_penalty=10, ) diff --git a/src/pwncore/models/user.py b/src/pwncore/models/user.py index 7eaad65..aab338d 100644 --- a/src/pwncore/models/user.py +++ b/src/pwncore/models/user.py @@ -35,8 +35,7 @@ async def save(self, *args, **kwargs): if self.team is not None and hasattr(self.team, "members"): count = await self.team.members.filter(~Q(id=self.pk)).count() if count >= 3: - raise IntegrityError( - "3 or more users already exist for the team") + raise IntegrityError("3 or more users already exist for the team") return await super().save(*args, **kwargs) diff --git a/src/pwncore/routes/admin.py b/src/pwncore/routes/admin.py index 86daec0..5551efa 100644 --- a/src/pwncore/routes/admin.py +++ b/src/pwncore/routes/admin.py @@ -30,7 +30,9 @@ async def init_db(): image_config={"PortBindings": {"22/tcp": [{}]}}, ) await Team.create(name="CID Squad", secret_hash=bcrypt.hash("veryverysecret")) - await Team.create(name="Triple A battery", secret_hash=bcrypt.hash("chotiwali"), coins=20) + await Team.create( + name="Triple A battery", secret_hash=bcrypt.hash("chotiwali"), coins=20 + ) await User.create( tag="23BRS1000", name="abc", diff --git a/src/pwncore/routes/auth.py b/src/pwncore/routes/auth.py index 649303f..4677a22 100644 --- a/src/pwncore/routes/auth.py +++ b/src/pwncore/routes/auth.py @@ -54,8 +54,7 @@ async def team_login(team_data: AuthBody, response: Response): return {"msg_code": config.msg_codes["wrong_password"]} current_time = datetime.datetime.utcnow() - expiration_time = current_time + \ - datetime.timedelta(hours=config.jwt_valid_duration) + expiration_time = current_time + datetime.timedelta(hours=config.jwt_valid_duration) token_payload = {"team_id": team.id, "exp": expiration_time} token = jwt.encode(token_payload, config.jwt_secret, algorithm="HS256") diff --git a/src/pwncore/routes/ctf/__init__.py b/src/pwncore/routes/ctf/__init__.py index 1bd2f92..125b737 100644 --- a/src/pwncore/routes/ctf/__init__.py +++ b/src/pwncore/routes/ctf/__init__.py @@ -12,7 +12,7 @@ ViewedHint, Problem_Pydantic, Hint_Pydantic, - Team + Team, ) from pwncore.config import config from pwncore.routes.ctf.start import router as start_router diff --git a/src/pwncore/routes/team.py b/src/pwncore/routes/team.py index 4e8aaaf..124613c 100644 --- a/src/pwncore/routes/team.py +++ b/src/pwncore/routes/team.py @@ -57,7 +57,7 @@ async def add_member(user: UserAddBody, response: Response, jwt: RequireJwt): name=user.name, email=user.email, phone_num=user.phone_num, - team_id=team_id + team_id=team_id, ) except Exception: response.status_code = 500 @@ -67,7 +67,7 @@ async def add_member(user: UserAddBody, response: Response, jwt: RequireJwt): @atomic() @router.post("/remove") -async def add_member(user_info: UserRemoveBody, response: Response, jwt: RequireJwt): +async def remove_member(user_info: UserRemoveBody, response: Response, jwt: RequireJwt): team_id = jwt["team_id"] user = await User.get_or_none(team_id=team_id, tag=user_info.tag)