Skip to content
Snippets Groups Projects
Commit cb7d01ac authored by Hervé  MENAGER's avatar Hervé MENAGER
Browse files

add first social authentication system (github)

Former-commit-id: 68d5cd12f8261618a02032b14b5e67c91f6b1291
parent b0cf9ee7
No related branches found
No related tags found
No related merge requests found
521ff1feba549fd94abfbcedbfea449190f6f3b2 fccd9d61cb42d14bf067967988c8ee76a6d781ff
\ No newline at end of file \ No newline at end of file
{% load socialaccount %}
<!DOCTYPE html> <!DOCTYPE html>
<html lang="en"> <html lang="en">
<head> <head>
...@@ -60,6 +62,11 @@ ...@@ -60,6 +62,11 @@
<li> <li>
<a href="/admin-session">Admin</a> <a href="/admin-session">Admin</a>
</li> </li>
{% if user.is_authenticated %}
<li>Welcome {{ user.username }} !!! <a href="{% url 'logout' %}">logout</a></li>
{% else %}
<li><a href="{% provider_login_url 'github' %}"><i class="fab fa-github" title="Login with github"></i> Login with GitHub</a></li>
{% endif %}
</ul> </ul>
</div> </div>
</nav> </nav>
......
...@@ -46,7 +46,12 @@ INSTALLED_APPS = [ ...@@ -46,7 +46,12 @@ INSTALLED_APPS = [
'ippidb', 'ippidb',
'formtools', 'formtools',
'debug_toolbar', 'debug_toolbar',
'mod_wsgi.server' 'mod_wsgi.server',
'django.contrib.sites',
'allauth',
'allauth.account',
'allauth.socialaccount',
'allauth.socialaccount.providers.github',
] ]
MIDDLEWARE = [ MIDDLEWARE = [
...@@ -140,3 +145,15 @@ GRAPH_MODELS = { ...@@ -140,3 +145,15 @@ GRAPH_MODELS = {
'all_applications': True, 'all_applications': True,
'group_models': True, 'group_models': True,
} }
# myproject/settings.py
AUTHENTICATION_BACKENDS = (
"django.contrib.auth.backends.ModelBackend",
"allauth.account.auth_backends.AuthenticationBackend",
)
SITE_ID = 1
LOGIN_REDIRECT_URL = '/'
LOGOUT_REDIRECT_URL = '/'
...@@ -19,4 +19,6 @@ from django.contrib import admin ...@@ -19,4 +19,6 @@ from django.contrib import admin
urlpatterns = [ urlpatterns = [
url(r'^', include('ippidb.urls')), url(r'^', include('ippidb.urls')),
url(r'^admin-django/', admin.site.urls), url(r'^admin-django/', admin.site.urls),
url(r'^accounts/', include('allauth.urls')),
url(r'^auth/', include('django.contrib.auth.urls')),
] ]
...@@ -9,3 +9,4 @@ django-formtools ...@@ -9,3 +9,4 @@ django-formtools
django-debug-toolbar django-debug-toolbar
mod_wsgi mod_wsgi
bioblend bioblend
django-allauth
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment