flask_more_smorest.perms.user_context

User context helpers for flask-more-smorest.

This module exposes runtime user lookup helpers and role checks. All configuration is driven through init_fms in user_registry.

Functions

get_current_user([user_type])

get_current_user_id()

Get the current authenticated user's ID.

is_current_user_admin()

Check if the current user is an admin.

is_current_user_superadmin()

Check if the current user is a superadmin.

flask_more_smorest.perms.user_context.get_current_user(user_type=None)[source]
Overloads:
  • AbstractUser | None

  • user_type (type[UserT]) → UserT | None

Get the current authenticated user.

Resolution order: 1. Registered custom getter (via init_fms) 2. Default: JWT-based authentication (built-in)

Parameters:

user_type (type[TypeVar(UserT, bound= AbstractUser)] | None) – Optional user class for typed return. If None, returns AbstractUser | None.

Returns:

Current user instance if authenticated, None otherwise

Return type:

UserT | AbstractUser | None

flask_more_smorest.perms.user_context.get_current_user_id()[source]

Get the current authenticated user’s ID.

Return type:

UUID | None

flask_more_smorest.perms.user_context.is_current_user_admin()[source]

Check if the current user is an admin.

Return type:

bool

flask_more_smorest.perms.user_context.is_current_user_superadmin()[source]

Check if the current user is a superadmin.

Return type:

bool