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
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
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 on lines +16 to +18
def _to_admin_user_schema(user: User) -> AdminUserSchema:
return AdminUserSchema(
id=user.id,
Copy link
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

return updated

return user
except HTTPException:
Copy link
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 ?


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

Copy link
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

session_id: str,
) -> bool:
if await is_session_blacklisted(redis, session_id):
return False
Copy link
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

if not user:
raise AppException.internal_error("Failed to update user")
return user
except HTTPException:
Copy link
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

logger.error("Failed to update user: %s", exc)
raise DBException.handle(exc)

async def delete_user(self, *, user_id: uuid.UUID) -> User:
Copy link
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

from app.core.constant import RedisKey
from app.infra.redis import RedisClient


Copy link
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
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