Skip to content

Feat/mobile user crud block auth#29

Merged
wailbentafat merged 29 commits intodevelopfrom
feat/mobile-user-crud-block-auth
Mar 23, 2026
Merged

Feat/mobile user crud block auth#29
wailbentafat merged 29 commits intodevelopfrom
feat/mobile-user-crud-block-auth

Conversation

@Tyjfre-j
Copy link
Copy Markdown
Collaborator

@Tyjfre-j Tyjfre-j commented Mar 20, 2026

Summary

  • Add blocked field to users (migration + sqlc).
  • Admin endpoints to create/list/get/update/delete users.
  • Block/unblock user endpoints.
  • Blocked users can’t log in.
  • Access + refresh tokens are blacklisted when user is blocked.

Copy link
Copy Markdown
Collaborator

@wailbentafat wailbentafat left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fix merge confilict also

Comment thread app/router/web/users.py Outdated
Comment on lines +16 to +18
def _to_admin_user_schema(user: User) -> AdminUserSchema:
return AdminUserSchema(
id=user.id,
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove this from logique router

Comment thread app/service/users.py Outdated
return updated

return user
except HTTPException:
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we dont have any http request why we check http request excceptions ?

Comment thread app/service/users.py Outdated

if await is_session_blacklisted(redis, session_id):
raise AppException.unauthorized("Token is blacklisted")

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

when we block user the db is our source of truth we just need one check so just remove this

Comment thread app/service/users.py Outdated
session_id: str,
) -> bool:
if await is_session_blacklisted(redis, session_id):
return False
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

here make the db ur source of truth mean check the db not redis

Comment thread app/service/users.py Outdated
if not user:
raise AppException.internal_error("Failed to update user")
return user
except HTTPException:
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same no http request

Comment thread app/service/users.py Outdated
logger.error("Failed to update user: %s", exc)
raise DBException.handle(exc)

async def delete_user(self, *, user_id: uuid.UUID) -> User:
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

when delete user if he have session remove it from redis

Comment thread app/core/token_blacklist.py Outdated
from app.core.constant import RedisKey
from app.infra.redis import RedisClient


Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this behaviour is wrong when we use session our source of truth is the database so when we check the database the user is blocked so when we block user we just remove the session from redis when we remove session from redis the code have to check the db and they found out that tht user is blocked this is the right behaviour

@Tyjfre-j Tyjfre-j force-pushed the feat/mobile-user-crud-block-auth branch from 5de2b46 to 5aa0cb8 Compare March 23, 2026 21:16
@Tyjfre-j Tyjfre-j changed the base branch from main to develop March 23, 2026 21:31
@wailbentafat wailbentafat merged commit 735cd62 into develop Mar 23, 2026
@Tyjfre-j Tyjfre-j deleted the feat/mobile-user-crud-block-auth branch April 11, 2026 20:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants