Skip to content
Browse files

Temporary commit so I can move stuff about.

  • Loading branch information...
1 parent 12ec235 commit 65c489c683631f44375f242d5701819330e29efd @mithro mithro committed
View
5 private/README
@@ -1,2 +1,3 @@
-The private repository which contains OAuth and similar keys should be checked
-out here.
+These keys are what secure the website login.
+
+ ** DO NOT SHARE PUBLICLY **
View
16 settings.py
@@ -155,14 +155,14 @@
'django.contrib.auth.backends.ModelBackend',
)
-LOGIN_URL = '/accounts/login/'
-LOGIN_ERROR_URL = '/accounts/error/'
-LOGIN_REDIRECT_URL = '/accounts/profile/'
-LOGOUT_URL = '/accounts/logout/'
-
-SOCIAL_AUTH_NEW_USER_REDIRECT_URL = '/accounts/new-users/'
-SOCIAL_AUTH_NEW_ASSOCIATION_REDIRECT_URL = '/accounts/new-association/'
-SOCIAL_AUTH_DISCONNECT_REDIRECT_URL = '/accounts/disconnected/'
+LOGIN_URL = '/accounts/login'
+LOGIN_ERROR_URL = '/accounts/error'
+LOGIN_REDIRECT_URL = '/accounts/profile'
+LOGOUT_URL = '/accounts/logout'
+
+SOCIAL_AUTH_NEW_USER_REDIRECT_URL = '/accounts/profile/new'
+SOCIAL_AUTH_NEW_ASSOCIATION_REDIRECT_URL = '/accounts/profile/association'
+SOCIAL_AUTH_DISCONNECT_REDIRECT_URL = '/accounts/disconnected'
SOCIAL_AUTH_ERROR_KEY = 'social_errors'
SOCIAL_AUTH_COMPLETE_URL_NAME = 'socialauth_complete'
SOCIAL_AUTH_ASSOCIATE_URL_NAME = 'socialauth_associate_complete'
View
2 urls.py
@@ -10,7 +10,7 @@
# admin pages
(r'^admin/', include(admin.site.urls)),
# auth specific urls
- (r'^', include('social_auth.urls')),
+ (r'^accounts/', include('social_auth.urls')),
# Our actual app
(r'^', include('usergroup.urls')),
)
View
55 usergroup/accounts.py
@@ -1,3 +1,8 @@
+#!/usr/bin/python
+#
+# -*- coding: utf-8 -*-
+# vim: set ts=4 sw=4 et sts=4 ai:
+
from django.http import HttpResponseRedirect
from django.contrib.auth import logout as auth_logout
from django.contrib.auth.decorators import login_required
@@ -5,30 +10,54 @@
from django.shortcuts import render_to_response
from django.contrib.messages.api import get_messages
-from social_auth import __version__ as version
+import social_auth.backends
+
+# Add in a URL which can be used to check it this person is logged into that service
+social_auth.backends.twitter.TwitterBackend.loggedin_test = 'https://twitter.com/account/use_phx?setting=false&format=text'
+social_auth.backends.facebook.FacebookBackend.loggedin_test = 'https://www.facebook.com/imike3'
+
+# List of providers to show in the top section
+PROVIDERS = {
+ 'Twitter': social_auth.backends.twitter.TwitterBackend,
+ 'Facebook': social_auth.backends.facebook.FacebookBackend,
+ 'Google' : social_auth.backends.google.GoogleBackend,
+ 'Yahoo': social_auth.backends.yahoo.YahooBackend,
+ 'LinkedIn': social_auth.backends.contrib.linkedin.LinkedinBackend,
+ 'FourSquare': social_auth.backends.contrib.foursquare.FoursquareBackend,
+ 'GitHub': social_auth.backends.contrib.github.GithubBackend,
+}
+
+# List of providers to show in the openid section
+OPENID_PROVIDERS = {
+ 'wordpress': '',
+ 'myspace': 'Username',
+ 'aol': 'Username',
+}
-def home(request):
- """Home view, displays login mechanism"""
+def login(request):
+ """Displays login mechanism"""
+ providers = PROVIDERS
+ openid_providers = OPENID_PROVIDERS
+
if request.user.is_authenticated():
- return HttpResponseRedirect('done')
+ return HttpResponseRedirect('profile')
else:
- return render_to_response('accounts/home.html', {'version': version},
- RequestContext(request))
+ return render_to_response('accounts/login.html', locals(), RequestContext(request))
+
@login_required
-def done(request):
+def profile(request):
"""Login complete view, displays user data"""
- ctx = {'version': version,
- 'last_login': request.session.get('social_auth_last_login_backend')}
- return render_to_response('accounts/done.html', ctx, RequestContext(request))
+ last_login = request.session.get('social_auth_last_login_backend')
+ return render_to_response('accounts/profile.html', locals(), RequestContext(request))
+
def error(request):
"""Error view"""
messages = get_messages(request)
- return render_to_response('accounts/error.html', {'version': version,
- 'messages': messages},
- RequestContext(request))
+ return render_to_response('accounts/error.html', locals(), RequestContext(request))
+
def logout(request):
"""Logs out user"""
View
61 usergroup/templates/accounts/base.html
@@ -1,61 +0,0 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml" xmlns:og="http://opengraphprotocol.org/schema/" xmlns:fb="http://www.facebook.com/2008/fbml">
- <head>
- <title>Django Social Auth</title>
- <meta name="description" content="Django Social Auth is an easy to setup social authentication/registration mechanism for Django projects." />
- <meta name="keywords" content="django, django login, django auth, django facebook, django twitter, django openid, django oauth, social auth, openid, oauth, twitter, facebook, google, yahoo, myopenid, python" />
- <meta http-equiv="Content-type" content="text/html;charset=UTF-8" />
- <style type="text/css">
- body {background-color: #eee; padding: 10px 20px; font-family: sans-serif; color: #333;}
- h1, h2, h3 {margin: 0; padding: 0;}
- h1 {font-size: 1.8em; border-bottom: 1px solid #bbb; width: 95%;}
- h2 {font-size: 1.3em; border-bottom: 1px solid #ddd; width: 85%;}
- h3 {font-size: 1.2em;}
- a, a:visited {color: #459FDA; text-decoration: none;}
- a:hover {text-decoration: underline;}
- a img {border: 0;}
- input[type="text"] {border: 1px solid #ccc; padding: 3px; width: 300px;}
- input[type="submit"] {padding: 2px 20px; margin-left: -5px;}
- label {display: block;}
- th {text-align: left; padding-right: 25px; font-weight: normal;}
- th, td {padding: 5px 15px;}
- tr.even {background-color: #ddd;}
- #heading {margin-top: 2.3em;}
- #content {padding: 0 20px;}
- .helptext {font-size: 0.9em; color: #aaa; margin: 0; padding: 0;}
- .description {font-size: 1.0em; color: #333;}
- a.logout, span.disconnect a, .error {color: #c00;}
- .error {padding-left: 30px;}
- #forkme {position: absolute; top: 0; right: 0;}
- #valid-badges {position: fixed; right: 10px; bottom: 10px;}
- #valid-badges p {display: inline;}
- </style>
- </head>
- <body>
- <h1>Django Social Auth (v{{ version }})</h1>
- <p class="description">
- Django Social Auth is an easy to setup social authentication/registration mechanism for Django projects.
- </p>
- <p>Check the documentation on <a href="https://github.com/omab/django-social-auth#readme" title="docs">Github</a></p>
-
- <h2 id="heading">{% block heading %}{% endblock %}</h2>
- <div id="content">
- {% block content %}{% endblock %}
- </div>
-
- <div id="valid-badges">
- <p>
- <a href="http://jigsaw.w3.org/css-validator/check/referer">
- <img style="border:0;width:88px;height:31px" src="http://jigsaw.w3.org/css-validator/images/vcss-blue" alt="Valid CSS!" />
- </a>
- </p>
- <p>
- <a href="http://validator.w3.org/check?uri=referer">
- <img src="http://www.w3.org/Icons/valid-xhtml10" alt="Valid XHTML 1.0 Strict" height="31" width="88" />
- </a>
- </p>
- </div>
-
- <div><a id="forkme" href="http://github.com/omab/django-social-auth"><img src="http://s3.amazonaws.com/github/ribbons/forkme_right_red_aa0000.png" alt="Fork me on GitHub" /></a></div>
- </body>
-</html>
View
6 usergroup/templates/accounts/error.html
@@ -1,8 +1,8 @@
-{% extends "accounts/base.html" %}
+{% extends "base.html" %}
-{% block heading %}Error!{% endblock %}
+{% block title %}Login Error :({% endblock %}
-{% block content %}
+{% block body %}
<div>
<p>Sorry but some error made you impossible to login.</p>
View
123 usergroup/templates/accounts/login.html
@@ -1,29 +1,88 @@
-{% extends "accounts/base.html" %}
+{% extends "base.html" %}
+{% comment %}
+-*- coding: utf-8 -*-
+vim: set ts=2 sw=2 et sts=2 ai:
+{% endcomment %}
-{% block heading %}Login using any of the following methods{% endblock %}
+{% block title %}Login!{% endblock %}
-{% block content %}
-<div>
- <h3>Login using <a href="http://oauth.net/" title="OAuth">OAuth</a> from:</h3>
- <ul>
- {% for name in social_auth.backends.oauth %}
- <li><a rel="nofollow" href="{% url socialauth_begin name %}">{{ name|title }}</a></li>
- {% endfor %}
- </ul>
-</div>
-
-<div>
- <h3>Login using <a href="http://tools.ietf.org/html/draft-ietf-oauth-v2-10" title="OAuth2">OAuth2</a> from:</h3>
- <ul>
- {% for name in social_auth.backends.oauth2 %}
- <li><a rel="nofollow" href="{% url socialauth_begin name %}">{{ name|title }}</a></li>
- {% endfor %}
- </ul>
-</div>
+{% block body %}
+
+<link href='http://fonts.googleapis.com/css?family=Homenaje' rel='stylesheet' type='text/css'>
+<style>
+
+td.or {
+ text-align: center;
+ font-family: 'Homenaje', sans-serif;
+ font-size: 32pt;
+ color: #aaa;
+ padding: 0;
+ margin: 0;
+}
+
+td.or hr {
+ color: #aaa;
+ background-color: #aaa;
+ border: 1px solid #aaa;
+}
+
+td.or-hr hr {
+ height: 2px;
+ width: 100%;
+}
+
+td.or-hr {
+ width: 40%;
+}
+
+td.or-middle {
+ width: 5%;
+}
-<div>
- <h3>Login using <a href="http://openid.net/" title="OpenId">OpenId</a> from:</h3>
- <ul>
+td.vor {
+ text-align: center;
+ font-family: 'Homenaje', sans-serif;
+ font-size: 32pt;
+ color: #ddd;
+ padding: 0;
+ margin: 0;
+}
+
+td.vor hr {
+ color: #ddd;
+ background-color: #ddd;
+ border: 1px solid #ddd;
+}
+
+td.vor-hr {
+ height: 10%;
+}
+
+td.vor-middle {
+ height: 5%;
+}
+
+td.vor-hr hr {
+ width: 2px;
+ height: 40px;
+}
+
+</style>
+
+
+<table>
+ <tr>
+ <td colspan=3 id=oauth>
+ {% for name, backend in providers.items %}
+ <li><a rel="nofollow" href="{% url socialauth_begin backend.name %}">{{ name }}</a></li>
+ {% endfor %}
+ </td>
+ </tr><tr>
+ <td class="or or-hr"><hr></td>
+ <td class="or or-middle">OR</td>
+ <td class="or or-hr"><hr></td>
+ </tr><tr>
+ <td colspan=3 id=openid>
{% for name in social_auth.backends.openid %}
<li>
{% if name != "livejournal" and name != "openid" %}
@@ -50,8 +109,20 @@
{% endif %}
{% endif %}
{% endif %}
- </li>
{% endfor %}
- </ul>
-</div>
+ </td>
+ </tr><tr>
+ <td class="or or-hr"><hr></td>
+ <td class="or or-middle">OR</td>
+ <td class="or or-hr"><hr></td>
+ </tr><tr>
+ <td id=login rowspan=3></td>
+ <td class="vor vor-hr"><hr></td>
+ <td id=register rowspan=3></td>
+ </tr><tr>
+ <td class="vor vor-middle">OR</td>
+ </tr><tr>
+ <td class="vor vor-hr"><hr></td>
+ </tr>
+</table>
{% endblock %}
View
6 usergroup/templates/accounts/done.html → usergroup/templates/accounts/profile.html
@@ -1,8 +1,8 @@
-{% extends "accounts/base.html" %}
+{% extends "base.html" %}
-{% block heading %}Logged in!{% endblock %}
+{% block title %}Logged in!{% endblock %}
-{% block content %}
+{% block body %}
<div>
<h3>User data:</h3>
<table>
View
14 usergroup/urls.py
@@ -5,13 +5,13 @@
urlpatterns = patterns(
'usergroup',
- url(r'^accounts/login/$', home, name='login'),
- url(r'^accounts/profile/$', done, name='profile'),
- url(r'^accounts/new-association/$', done, name='profile'),
- url(r'^accounts/new-account/$', done, name='profile'),
- url(r'^accounts/disconnected/$', done, name='profile'),
- url(r'^accounts/error/$', error, name='error'),
- url(r'^accounts/logout/$', logout, name='logout'),
+ url(r'^accounts/login$', login, name='login'),
+ url(r'^accounts/profile$', profile, name='profile'),
+ url(r'^accounts/profile/association$', profile, name='profile'),
+ url(r'^accounts/profile/disconnected$', profile, name='profile'),
+ url(r'^accounts/profile/new$', profile, name='profile'),
+ url(r'^accounts/error$', error, name='error'),
+ url(r'^accounts/logout$', logout, name='logout'),
# iCal feeds
(r'^ical[/]?[^\.]*(?:.ics)?', 'ical.handler', {}),

0 comments on commit 65c489c

Please sign in to comment.
Something went wrong with that request. Please try again.