Metadata-Version: 2.1
Name: cha_authentication
Version: 0.5.0
Summary: A Django app for multi-token authentication, and some other stuff.
Home-page: https://github.com/Simouche/cha_authentication
Author: Wassim Chaguetmi
Author-email: wassim.chaguetmi@gmail.com
Classifier: Development Status :: 3 - Alpha
Classifier: Framework :: Django
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.12
Description-Content-Type: text/markdown
Requires-Dist: Django>=5.1
Requires-Dist: djangorestframework>=3.12
Requires-Dist: django-simple-history>=3.2.0

# Authentication

A Django app for multi-token authentication.

## Installation

```bash
pip install authentication
```

##  Usage

Add authentication to your `INSTALLED_APPS` in your Django settings.

```python
INSTALLED_APPS = [
   'authentication',
]
```


### Custom User Validation

To add custom validation to the login process, follow these steps:

1. **Define the Custom Validation Function:**

   Create a custom validation function in a module. This function should accept a `user` object and perform the necessary validation.

   ```python
   # authentication/custom_validations.py
   from django.core.exceptions import PermissionDenied
   from django.utils.translation import gettext as _

   def custom_user_validation(user):
       if not user.is_active:
           raise PermissionDenied(_("User is not active."), 'inactive_user')
   ```

2. **Update the Settings:**

   In your `settings.py` file, add the `MORE_USER_VALIDATION` setting and set it to the path of your custom validation function.

   ```python
   # cha_auth/settings.py
   MORE_USER_VALIDATION = 'authentication.custom_validations.custom_user_validation'
   ```

By following these steps, you can add custom validation to the login process without modifying the URL configuration. Users can specify their custom validation function in the `MORE_USER_VALIDATION` setting, and it will be called during the login process.
