Skip to content
This repository has been archived by the owner on May 5, 2020. It is now read-only.

Commit

Permalink
docs: Update README
Browse files Browse the repository at this point in the history
  • Loading branch information
rubengrill authored and relekang committed Sep 14, 2018
1 parent deba82e commit ca81820
Showing 1 changed file with 62 additions and 5 deletions.
67 changes: 62 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Run this command to install django-nopassword
pip install django-nopassword

### Requirements
Django >= 1.4 (1.5 custom user is supported)
Django >= 1.11 (custom user is supported)

## Usage
Add the app to installed apps
Expand All @@ -22,26 +22,83 @@ INSTALLED_APPS = (
)
```

Set the authentication backend to *EmailBackend*
Add the authentication backend *EmailBackend*

AUTHENTICATION_BACKENDS = ('nopassword.backends.email.EmailBackend',)
```python
AUTHENTICATION_BACKENDS = (
# Needed to login by username in Django admin, regardless of `nopassword`
'django.contrib.auth.backends.ModelBackend',

# Send login codes via email
'nopassword.backends.email.EmailBackend',
)
```

Add urls to your *urls.py*

```python
urlpatterns = patterns('',
...
url(r'^accounts/', include('nopassword.urls', namespace='nopassword')),
url(r'^accounts/', include('nopassword.urls')),
...
)
```

### REST API

To use the REST API, *djangorestframework* must be installed

pip install djangorestframework

Add rest framework to installed apps

```python
INSTALLED_APPS = (
...
'rest_framework',
'rest_framework.authtoken',
'nopassword',
...
)
```

Add *TokenAuthentication* to default authentication classes

```python
REST_FRAMEWORK = {
'DEFAULT_AUTHENTICATION_CLASSES': (
'rest_framework.authentication.TokenAuthentication',
)
}
```

Add urls to your *urls.py*

```python
urlpatterns = patterns('',
...
url(r'^api/accounts/', include('nopassword.rest.urls')),
...
)
```

You will have the following endpoints available:

- `/api/accounts/login/` (POST)
- username
- next (optional, will be returned in `/api/accounts/login/code/` to be handled by the frontend)
- Sends a login code to the user
- `/api/accounts/login/code/` (POST)
- code
- Returns `key` (authentication token) and `next` (provided by `/api/accounts/login/`)
- `/api/accounts/logout/` (POST)
- Performs logout

### Settings
Information about the available settings can be found in the [docs](http://django-nopassword.readthedocs.org/en/latest/#settings)

## Tests
Run with `python setup.py test`.
To run with sqlite add `USE_SQLITE = True` in tests/local.py

--------
MIT © Rolf Erik Lekang

0 comments on commit ca81820

Please sign in to comment.