Skip to content

Commit

Permalink
cleanup and readme
Browse files Browse the repository at this point in the history
  • Loading branch information
omercnet committed Mar 20, 2023
1 parent 74e1676 commit 8a25c95
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 12 deletions.
3 changes: 3 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,12 @@ repos:
rev: 1.4.0
hooks:
- id: poetry-check
files: pyproject.toml
- id: poetry-lock
files: pyproject.toml
- id: poetry-export
args: ["-f", "requirements.txt", "-o", "requirements.txt"]
files: pyproject.toml
- repo: https://github.com/dhatim/python-license-check
rev: 0.8.3
hooks:
Expand Down
25 changes: 16 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,23 +41,30 @@ _The names of these roles can be customized in the settings below._
path('auth/', include('django_descope.urls')),
```

1. Start the development server and visit http://127.0.0.1:8000/auth/signup
1. In your site templates, insert the `descope_flow` tag where you want to place your flow

```html
{% load descope %}
<!-- load the descope registry -->

{% if user.is_authenticated %}
<h1>Welcome {{ user.email }} you are logged in!</h1>
<p><a href="{% url 'logout' %}">Log Out</a></p>
{% else %} {% descope_flow "sign-up-or-in" "/" %}
<!-- provide the descope flow id, and where to redirect after a successful login-->
{% endif %}
```

2. Start the development server and visit http://127.0.0.1:8000/auth/signup

1. Visit http://127.0.0.1:8000/auth/tokens to see the user tokens after login
3. Visit http://127.0.0.1:8000/auth/tokens to see the user tokens after login

## Settings

The following settings are available to configure in your project `settings.py`

```
DESCOPE_PROJECT_ID **Required**
DESCOPE_REQUIRE_SIGNUP - Set this to true to create user on first login
DESCOPE_LOGIN_SENT_REDIRECT
DESCOPE_LOGIN_SUCCESS_REDIRECT
DESCOPE_LOGIN_TEMPLATE_NAME
DESCOPE_LOGIN_SENT_TEMPLATE_NAME
DESCOPE_LOGIN_FAILED_TEMPLATE_NAME
DESCOPE_SIGNUP_TEMPLATE_NAME
DESCOPE_IS_STAFF_ROLE
DESCOPE_IS_SUPERUSER_ROLE
```
1 change: 0 additions & 1 deletion django_descope/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ def post(self, request: HttpRequest):
session = request.POST.get(SESSION_COOKIE_NAME)
refresh = request.POST.get(REFRESH_SESSION_COOKIE_NAME)
if session and refresh:
# descope_client.validate_and_refresh_session(session, refresh)
request.session[SESSION_COOKIE_NAME] = session
request.session[REFRESH_SESSION_COOKIE_NAME] = refresh
return JsonResponse({"success": True})
Expand Down
2 changes: 0 additions & 2 deletions settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,6 @@
},
}

LOGIN_REDIRECT_URL = "/admin"

INTERNAL_IPS = [
"127.0.0.1",
]

0 comments on commit 8a25c95

Please sign in to comment.