Anonymous avatar Anonymous committed 0de27a8

[svn r41] from suggestion of rossp (issue #11 & #12)

Comments (0)

Files changed (8)

+django-authopenid AUTHORS
+=========================
+
+django-athopenid was originally developed by Benoit Chesneau <bchesneau@gmail.com> and
+he remains the project lead.
+
+For a list of other credits see the `THANKS` file.
-Copyright (c) 2007, Benoît Chesneau
+Copyright (c) 2007, 2008, Benoît Chesneau
 
 All rights reserved.
 
+django-authopenid NOTICE
+========================
+
+Core software:
+ * Copyright 2007, 2008 Benoit Chesneau <bchesneau@gmail.com>
+
+Based on: 
+ * django-openid, Copyright 2007 Simon Willison
   * /account/signout : signout url
   * /account/signin/complete/ : register openid after signin 
   * /account/signup : legacy authentification 
-  * /account/password : send a new password
+  * /account/sendpw/password : send a new password
   * /account/password/confirm : confirm change of password
  * account settings : 
-  * /acount/username : main page of account for user with username _username_
-  * /account/username/password: change password page
-  * /account/username/email : change email page
-  * /account/username/delete : delete account
-  * /account/username/openid : associate a new openid for an account.
+  * /acount : main page of account for user  
+  * /account/password: change password page
+  * /account/email : change email page
+  * /account/delete : delete account
+  * /account/openid : associate a new openid for an account.
 
 == templates ==
 
+django-authopenid THANKS
+========================
+
+django-authopenid was originally developed by Benoît Chesneau <bchesneau@gmail.com>
+and a number of other contributors. Many people further contributed to django-authopenid
+by reporting problems, suggesting various improvements or submitting
+changes. A list of these people is included below.
+
+* David Larlet <http://david.larlet.fr> 
+* Ross Poulton <ross@rossp.org>
+
+and many other anonymous.
 # -*- coding: utf-8 -*-
 """
- Copyright (c) 2007, Benoît Chesneau
+ Copyright (c) 2007, 2008, Benoît Chesneau
 
  All rights reserved.
 
     url(r'^%s%s$' % (_('signin/'), _('complete/')), 'complete_signin', name='user_complete_signin'),
     url(r'^%s$' % _('register/'), 'register', name='user_register'),
     url(r'^%s$' % _('signup/'), 'signup', name='user_signup'),
-    url(r'^%s$' % _('password/'), 'sendpw', name='user_sendpw'),
+    url(r'^%s$' % _('sendpw/'), 'sendpw', name='user_sendpw'),
     url(r'^%s%s$' % (_('password/'), _('confirm/')), 'confirmchangepw', name='user_confirmchangepw'),
 
     # manage account settings
-    url(r'^(?P<username>\w+)/$', 'account_settings', name='user_account_settings'),
     url(r'^$', 'account_settings', name='user_account_settings'),
-    url(r'^(?P<username>\w+)/%s$' % _('password/'), 'changepw', name='user_changepw'),
-    url(r'^(?P<username>\w+)/%s$' % _('email/'), 'changeemail', name='user_changeemail'),
-    url(r'^(?P<username>\w+)/%s$' % _('openid/'), 'changeopenid', name='user_changeopenid'),
-    url(r'^(?P<username>\w+)/%s$' % _('delete/'), 'delete', name='user_delete'),
+    url(r'^%s$' % _('password/'), 'changepw', name='user_changepw'),
+    url(r'^%s$' % _('email/'), 'changeemail', name='user_changeemail'),
+    url(r'^%s$' % _('openid/'), 'changeopenid', name='user_changeopenid'),
+    url(r'^%s$' % _('delete/'), 'delete', name='user_delete'),
     
     
 )
 # -*- coding: utf-8 -*-
 """
- Copyright (c) 2007, Benoît Chesneau
+ Copyright (c) 2007, 2008, Benoît Chesneau
  Copyright (c) 2007, Simon Willison, original work on django-openid
 
  All rights reserved.
         OpenidVerifyForm, RegistrationForm, ChangepwForm, ChangeemailForm, \
         ChangeopenidForm, DeleteForm, EmailPasswordForm
 
-from decorators import username_control
-
 def get_url_host(request):
     if request.is_secure():
         protocol = 'https'
         'action_signin': action_signin,
         },context_instance=RequestContext(request))
 
-@login_required
 def signout(request):
     """
     signout from the website. Remove openid from session and kill it.
     logout(request)
     
     return HttpResponseRedirect(next)
+signout = login_required(signout)
 
-
-@login_required
-@username_control ('user_account_settings')
-def account_settings(request,username=None):
+def account_settings(request):
     """
     index pages to changes some basic account settings :
      - change password
      - associate a new openid
      - delete account
 
-    url : /username/
+    url : /
 
     template : authopenid/settings.html
     """
     is_openid = True
 
     try:
-        o=UserAssociation.objects.get(user__username__exact=username)
+        o=UserAssociation.objects.get(user__username__exact=request.user.username)
     except:
         is_openid = False
 
     return render('authopenid/settings.html',
             {'msg': msg, 'settings_path': request.path, 'is_openid': is_openid},
             context_instance=RequestContext(request))
+account_settings = login_required(account_settings)
 
-@login_required
-@username_control('user_changepw')
-def changepw(request,username):
+def changepw(request):
     """
     change password view.
 
-    url : /username/changepw/
+    url : /changepw/
     template: authopenid/changepw.html
     """
     
-    u = get_object_or_404(User, username=username)
+    u = request.user
     
     if request.POST:
         form = ChangepwForm(request.POST)
             u.set_password(form.cleaned_data['password1'])
             u.save()
             msg=_("Password changed.") 
-            redirect="%s?msg=%s" % (reverse('user_account_settings',kwargs={'username': request.user.username}),urlquote_plus(msg))
+            redirect="%s?msg=%s" % (reverse('user_account_settings'),urlquote_plus(msg))
             return HttpResponseRedirect(redirect)
     else:
-        form=ChangepwForm(initial={'username':request.user.username})
+        form=ChangepwForm(initial={'username':u.username})
 
     return render('authopenid/changepw.html', {'form': form },
                                 context_instance=RequestContext(request))
+changepw = login_required(changepw)
 
-@login_required
-@username_control('user_changeemail')
-def changeemail(request,username):
+def changeemail(request):
     """ 
     changeemail view. It require password or openid to allow change.
 
-    url: /username/changeemail/
+    url: /changeemail/
 
     template : authopenid/changeemail.html
     """
 
     extension_args = {}
  
-    u = get_object_or_404(User, username=username) 
+    u = request.user
     
-    redirect_to = get_url_host(request) + reverse('user_changeemail',kwargs={'username':username})
+    redirect_to = get_url_host(request) + reverse('user_changeemail')
 
     if request.POST:
         form = ChangeemailForm(request.POST)
                 u.email = form.cleaned_data['email']
                 u.save()
                 msg=_("Email changed.") 
-                redirect="%s?msg=%s" % (reverse('user_account_settings', kwargs={'username': request.user.username}),urlquote_plus(msg))
+                redirect="%s?msg=%s" % (reverse('user_account_settings'),urlquote_plus(msg))
                 return HttpResponseRedirect(redirect)
             else:
                 request.session['new_email'] = form.cleaned_data['email']
     else:
         form = ChangeemailForm(initial={
                                         'email': u.email,
-                                        'username':request.user.username
+                                        'username': u.username
                                         })
     
     return render('authopenid/changeemail.html', 
             {'form': form }, context_instance=RequestContext(request))
+changeemail = login_required(changeemail)
 
 def emailopenid_success(request, identity_url, openid_response):
     openid=from_openid_response(openid_response)
         del request.session['new_email']
     msg=_("Email Changed.")
 
-    redirect="%s?msg=%s" % (reverse('user_account_settings',kwargs={'username': request.user.username}),urlquote_plus(msg))
+    redirect="%s?msg=%s" % (reverse('user_account_settings'),urlquote_plus(msg))
     return HttpResponseRedirect(redirect)
     
 
 def emailopenid_failure(request, message):
-    redirect_to="%s?msg=%s" % (reverse('user_changeemail',kwargs={'username':request.user.username}), urlquote_plus(message))
-
+    redirect_to="%s?msg=%s" % (reverse('user_changeemail'), urlquote_plus(message))
     return HttpResponseRedirect(redirect_to)
  
 
-@login_required
-@username_control('user_changeopenid')
-def changeopenid(request, username):
+def changeopenid(request):
     """
     change openid view. Allow user to change openid associated to its username.
 
-    url : /username/changeopenid/
+    url : /changeopenid/
 
     template: authopenid/changeopenid.html
     """
     has_openid=True
     msg = request.GET.get('msg', '')
         
-    u = get_object_or_404(User, username=username)
+    u = request.user
 
     try:
         uopenid=UserAssociation.objects.get(user=u)
     except:
         has_openid=False
     
-    redirect_to = get_url_host(request) + reverse('user_changeopenid',kwargs={'username':username})
+    redirect_to = get_url_host(request) + reverse('user_changeopenid')
     if request.POST and has_openid:
         form=ChangeopenidForm(request.POST)
         if form.is_valid():
         if 'openid.mode' in request.GET:
             return complete(request, changeopenid_success, changeopenid_failure, redirect_to)    
 
-    form = ChangeopenidForm(initial={'openid_url': openid_url, 'username':request.user.username })
+    form = ChangeopenidForm(initial={'openid_url': openid_url, 'username':u.username })
     return render('authopenid/changeopenid.html', {'form': form,
         'has_openid': has_openid, 'msg': msg }, context_instance=RequestContext(request))
-
+changeopenid = login_required(changeopenid)
 
 def changeopenid_success(request, identity_url, openid_response):
     openid=from_openid_response(openid_response)
     request.session['openids'].append(openid)
 
     msg=_("Openid %s associated with your account." % identity_url) 
-    redirect="%s?msg=%s" % (reverse('user_account_settings', kwargs={'username':request.user.username}), urlquote_plus(msg))
+    redirect="%s?msg=%s" % (reverse('user_account_settings'), urlquote_plus(msg))
     return HttpResponseRedirect(redirect)
     
 
 def changeopenid_failure(request, message):
-    redirect_to="%s?msg=%s" % (reverse('user_changeopenid',kwargs={'username':request.user.username}), urlquote_plus(message))
+    redirect_to="%s?msg=%s" % (reverse('user_changeopenid'), urlquote_plus(message))
     return HttpResponseRedirect(redirect_to)
   
 
-@login_required
-@username_control('user_delete')
-def delete(request,username):
+def delete(request):
     """
     delete view. Allow user to delete its account. Password/openid are required to 
     confirm it. He should also check the confirm checkbox.
 
-    url : /username/delete
+    url : /delete
 
     template : authopenid/delete.html
     """
 
     extension_args={}
     
-    u = get_object_or_404(User, username=username)
+    u = request.user
 
-    redirect_to = get_url_host(request) + reverse('user_delete',kwargs={'username':username}) 
+    redirect_to = get_url_host(request) + reverse('user_delete') 
     if request.POST:
         form = DeleteForm(request.POST)
         if form.is_valid():
     elif not request.POST and 'openid.mode' in request.GET:
         return complete(request, deleteopenid_success, deleteopenid_failure, redirect_to) 
     
-    form = DeleteForm(initial={'username': username})
+    form = DeleteForm(initial={'username': u.username})
 
     msg = request.GET.get('msg','')
     return render('authopenid/delete.html', {'form': form, 'msg': msg, },
                                         context_instance=RequestContext(request))
-
+delete = login_required(delete)
 
 def deleteopenid_success(request, identity_url, openid_response):
     openid=from_openid_response(openid_response)
     
 
 def deleteopenid_failure(request, message):
-    redirect_to="%s?msg=%s" % (reverse('user_delete',kwargs={'username':request.user.username}), urlquote_plus(message))
-
+    redirect_to="%s?msg=%s" % (reverse('user_delete'), urlquote_plus(message))
     return HttpResponseRedirect(redirect_to)
 
 
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.