]> git.parisson.com Git - django-social-auth.git/commitdiff
Minor style updates.
authorStas Kravets <skravets@internal-rfc1918.hn.nnov.stream.ru>
Thu, 13 Jan 2011 15:09:24 +0000 (18:09 +0300)
committerStas Kravets <skravets@internal-rfc1918.hn.nnov.stream.ru>
Thu, 13 Jan 2011 15:09:24 +0000 (18:09 +0300)
example/app/views.py
example/settings.py
example/templates/home.html
social_auth/auth.py
social_auth/backends.py
social_auth/conf.py

index edc106289b65a8b9f44689cee5f00cf338aafc19..74d2cffddb2188962925852d47aa929e76bcc65f 100644 (file)
@@ -11,13 +11,6 @@ def home(request):
         return HttpResponseRedirect('done')
     else:
         return render_to_response('home.html', None, RequestContext(request))
-                <form action="/login/lj/" method="post">{% csrf_token %}
-                  <label for="openid_lj_user">LiveJournal user:</label>
-                  <input id="openid_lj_user" type="text" value="" name="openid_lj_user" />
-                  <input type="submit" />
-                </form>
-              </li>
-              <li>
 
 @login_required
 def done(request):
index 84716d204c38f281c50a8de286e2bd3ccad5664b..952a25eda5f2b67e1effacb2fd19e7348db7b65f 100644 (file)
@@ -70,6 +70,7 @@ AUTHENTICATION_BACKENDS = (
     'social_auth.backends.GoogleBackend',
     'social_auth.backends.YahooBackend',
     'social_auth.backends.OpenIDBackend',
+    'social_auth.backends.LiveJournalBackend',
     'django.contrib.auth.backends.ModelBackend',
 )
 
index aae415a18da760983f68cef6a7e5ca39d15f6467..6b513eef63515d020a155939903f9f8ee2682a88 100644 (file)
   <ul>
     <li><a rel="nofollow" href="/login/google/">Google</a></li>
     <li><a rel="nofollow" href="/login/yahoo/">Yahoo</a></li>
+       <li>
+         <form action="/login/livejournal/" method="post">{% csrf_token %}
+           <div>
+          <label for="openid_lj_user">LiveJournal user:</label>
+          <input id="openid_lj_user" type="text" value="" name="openid_lj_user" />
+          <input type="submit" value="Login"/>
+               </div>
+      </form>
+    </li>
     <li>
       <form action="/login/openid/" method="post">{% csrf_token %}
         <div>
index bd055cc8712215ee1944cbbe2c8d1ba23bf9b169..132e1d11ddcdfe4f0e906160b3a5d9bc4ef9f637 100644 (file)
@@ -15,10 +15,10 @@ from django.contrib.auth import authenticate
 
 from .store import DjangoOpenIDStore
 from .backends import TwitterBackend, OrkutBackend, FacebookBackend, \
-                      OpenIDBackend, GoogleBackend, YahooBackend
+                      OpenIDBackend, GoogleBackend, YahooBackend, LiveJournalBackend
 from .conf import AX_ATTRS, SREG_ATTR, OPENID_ID_FIELD, SESSION_NAME, \
                   OPENID_GOOGLE_URL, OPENID_YAHOO_URL, TWITTER_SERVER, \
-                  OPENID_LJ_URL, OPENID_LJ_USER_FIELD, \
+                  OPENID_LIVEJOURNAL_URL, OPENID_LIVEJOURNAL_USER_FIELD, \
                   TWITTER_REQUEST_TOKEN_URL, TWITTER_ACCESS_TOKEN_URL, \
                   TWITTER_AUTHORIZATION_URL, TWITTER_CHECK_AUTH, \
                   FACEBOOK_CHECK_AUTH, FACEBOOK_AUTHORIZATION_URL, \
@@ -168,15 +168,16 @@ class YahooAuth(OpenIdAuth):
 
 class LiveJournalAuth(OpenIdAuth):
     """LiveJournal OpenID authentication"""
+    AUTH_BACKEND = LiveJournalBackend
     def uses_redirect(self):
         """LiveJournal uses redirect"""
         return True
     
     def openid_url(self):
         """Returns LJ authentication URL"""
-        if self.request.method != 'POST' or OPENID_LJ_USER_FIELD not in self.request.POST or len(self.request.POST[OPENID_LJ_USER_FIELD]) == 0:
+        if self.request.method != 'POST' or not self.request.POST.get(OPENID_LIVEJOURNAL_USER_FIELD):
             raise ValueError, 'Missing LiveJournal user identifier'
-        return OPENID_LJ_URL % self.request.POST[OPENID_LJ_USER_FIELD]
+        return OPENID_LIVEJOURNAL_URL % self.request.POST[OPENID_LIVEJOURNAL_USER_FIELD]
 
 class BaseOAuth(BaseAuth):
     """OAuth base class"""
@@ -397,6 +398,7 @@ BACKENDS = {
     'facebook': FacebookAuth,
     'google': GoogleAuth,
     'yahoo': YahooAuth,
+    'livejournal': LiveJournalAuth,
     'orkut': OrkutAuth,
     'openid': OpenIdAuth,
 }
index 3c8eade51ed2425f14c1979b614de6af389d9160..17da9566cfbddd5b64d46ed5ea42a99bf94acc19 100644 (file)
@@ -111,9 +111,9 @@ class SocialAuthBackend(ModelBackend):
         
         if not getattr(settings, 'SOCIAL_AUTH_CHANGE_SIGNAL_ONLY', False):
             for name, value in details.iteritems():
-            # not update username if user already exists
-            if not new_user and name == USERNAME:
-                continue
+                # not update username if user already exists
+                if not new_user and name == USERNAME:
+                    continue
                 if value and value != getattr(user, name, value):
                     setattr(user, name, value)
                     changed = True
@@ -258,3 +258,7 @@ class GoogleBackend(OpenIDBackend):
 class YahooBackend(OpenIDBackend):
     """Yahoo OpenID authentication backend"""
     name = 'yahoo'
+
+class LiveJournalBackend(OpenIDBackend):
+    """LJ OpenID authentication backend"""
+    name = 'livejournal'
\ No newline at end of file
index a2cec516d2d0c851972230cd6e08708f9e422829..2fa337b82031b697ca78aca69c1fc7f46ecb328d 100644 (file)
@@ -45,5 +45,5 @@ OPENID_ID_FIELD = 'openid_identifier'
 SESSION_NAME = 'openid'
 OPENID_GOOGLE_URL      = 'https://www.google.com/accounts/o8/id'
 OPENID_YAHOO_URL = 'http://yahoo.com'
-OPENID_LJ_URL          = 'http://%s.livejournal.com'
-OPENID_LJ_USER_FIELD   = 'openid_lj_user'
\ No newline at end of file
+OPENID_LIVEJOURNAL_URL = 'http://%s.livejournal.com'
+OPENID_LIVEJOURNAL_USER_FIELD = 'openid_lj_user'
\ No newline at end of file