Django custom app to handle account functionality in a Django Web Application such as creating users (for Authentication/Authorization) and user-profiles (to stored additional user data and configurations).
This application solves the overhead of having to build a custom django application for account management which uses email/password as authentication factors from scratch, the codebase is constantly updated and improved to fixed known bugs and vulnerability and improve efficiency.
- ✔ Uses Email for User Authentication
- ✔ Provides Profile Model which extends the User model to store non-authentication related data
- ✔ Provides Support Both Vanilla Django (Template system) and Django RestFramework (Rest API)
- ✔ User authentication and authorization using token-based authentication (Rest API)
- Clone the repo into a local machine:
git clone https://github.com/brianobot/account_app.git
- Rename the repo directory to
accounts
and move into your Django project base directory (same level as manage.py)mv accounts_app accounts
- Open the Folder (Containing your Django Project) in any IDE of your choice (you can optionally work from Your File Explorer view)
- Add the
accounts.apps.AccountAppConfig
to your list of installed application in yoursettings.py
file - Add the following lines to your project's settings (
settings.py
)AUTH_USER_MODEL = 'accounts.User' LOGIN_REDIRECT_URL = "/" LOGOUT_REDIRECT_URL = '/' # rethink this process LOGIN_URL = 'accounts:login-account'
- Make sure this line is in your accounts
__init__.py
filedefault_app_config = 'accounts.apps.AccountsConfig'
- Make sure this line is in your accounts
apps.py
fileclass AccountConfig(AppConfig): ... def ready(self): import signals
- All the following url paths to your project's main url file
urlpatterns = [ ... path('account/', include('accounts.api.urls')) path('account/', include('accounts.page.urls')) ... ]
Customize as it fits your needs
The API has the following endpoints for authentication
accounts/api/v1/api-token-auth/
: Endpoint for obtaining tokensaccounts/api/v1/signup/
: Endpoint for Creating a user instance in the systemaccounts/api/v1/login/
: Endpoint for Authenicating a user, returns auth tokenaccounts/api/v1/users/
: List all the user currently registered on the system
If you come across a piece of code that could benefit from an improvement, document process and reason for improvement, and create a pull request to the original repository
Brian Obot brianobot9@gmail.com