Changeset 1416
- Timestamp:
- 02/16/08 13:24:37 (2 years ago)
- Location:
- trunk
- Files:
-
- 9 modified
-
AUTHORS (modified) (1 diff)
-
pylucid/PyLucid/index.py (modified) (4 diffs)
-
pylucid/PyLucid/plugins_internal/auth/auth.py (modified) (13 diffs)
-
pylucid/PyLucid/plugins_internal/auth/internal_pages/input_password.html (modified) (1 diff)
-
pylucid/PyLucid/plugins_internal/auth/internal_pages/input_username.html (modified) (1 diff)
-
pylucid/PyLucid/plugins_internal/auth/internal_pages/plaintext_login.html (modified) (1 diff)
-
pylucid/PyLucid/system/detect_page.py (modified) (2 diffs)
-
pylucid/PyLucid/system/exceptions.py (modified) (2 diffs)
-
pylucid/PyLucid/system/plugin_manager.py (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/AUTHORS
r1395 r1416 12 12 13 13 CONTRIBUTORS: 14 IbOn <ibonso@gmail.com> 14 rantaaho <rantaaho@gmail.com> 15 IbOn <ibonso@gmail.com> 15 16 Guido Leisker <http://www.guido-leisker.de> 16 17 Alen Hopek <http://www.mactricks.de> -
trunk/pylucid/PyLucid/index.py
r1339 r1416 20 20 import datetime, md5 21 21 22 from django.http import HttpResponse, HttpResponsePermanentRedirect 22 from django.http import HttpResponse, HttpResponsePermanentRedirect, HttpResponseRedirect 23 23 from django.template import RequestContext 24 24 from django.core.cache import cache … … 32 32 from PyLucid.system import plugin_manager 33 33 from PyLucid.system.response import SimpleStringIO 34 from PyLucid.system.exceptions import AccessDen y34 from PyLucid.system.exceptions import AccessDenied 35 35 from PyLucid.system.page_msg import PageMessages 36 36 from PyLucid.system.detect_page import get_current_page_obj, \ … … 210 210 211 211 # Get the response for the requested cms page: 212 current_page_obj = get_current_page_obj(request, url) 213 context = _get_context(request, current_page_obj) 214 response = _render_cms_page(context) 212 try: 213 current_page_obj = get_current_page_obj(request, url) 214 context = _get_context(request, current_page_obj) 215 response = _render_cms_page(context) 216 except AccessDenied: 217 # FIXME: We should build the command url in a better way 218 # Don't insert a hardcoded ID! Use the default ID. 219 next = '?next=%s' % request.path 220 path = '/'.join( 221 ('',settings.COMMAND_URL_PREFIX,'1','auth','login',next) 222 ) 223 return HttpResponseRedirect(path) 215 224 216 225 if use_cache: … … 268 277 context, local_response, module_name, method_name, url_args 269 278 ) 270 except AccessDen y:271 page_content = "[Permission Den y!]"279 except AccessDenied: 280 page_content = "[Permission Denied!]" 272 281 else: 273 282 if output == None: -
trunk/pylucid/PyLucid/plugins_internal/auth/auth.py
r1286 r1416 1 1 #!/usr/bin/python 2 # -*- coding: UTF-8 -*-2 # -*- coding: utf-8 -*- 3 3 4 4 """ … … 27 27 import datetime 28 28 29 from django.http import HttpResponseRedirect 29 30 from django.core import mail 30 31 from django import newforms as forms … … 149 150 150 151 UsernameForm = forms.form_for_model(User, fields=("username",)) 152 153 next_url = self.request.GET.get('next',self.URLs['scriptRoot']) 151 154 152 155 def get_data(form): … … 192 195 self.page_msg.red("Wrong POST data.") 193 196 197 if DEBUG: self.page_msg("Next URL: %s" % next_url) 194 198 195 199 context = { 196 200 "fallback_url": self.URLs.adminLink(""), 197 201 "form": username_form, 202 "next_url": next_url, 198 203 } 199 204 self._render_template("input_username", context)#, debug=True) … … 209 214 210 215 PasswordForm = forms.form_for_model(User, fields=("password",)) 216 217 next_url = self.request.POST.get('next_url',self.URLs['scriptRoot']) 211 218 212 219 # Change the default TextInput to a PasswordInput … … 216 223 "username": user.username, 217 224 "logout_url": self.URLs.methodLink("logout"), 225 "next_url": next_url, 218 226 } 219 227 … … 232 240 else: 233 241 # Login ok 234 return 242 return HttpResponseRedirect(next_url) 235 243 236 244 context["form"] = password_form … … 260 268 # rebuild the login/logout link: 261 269 add_dynamic_context(self.request, self.context) 270 271 next_url = self.request.POST.get('next_url',self.URLs['scriptRoot']) 272 273 # Redirect to next URL 274 HttpResponseRedirect(next_url) 262 275 263 276 … … 276 289 self.pass_reset(user.username, msg) # Display the pass reset form 277 290 return 278 291 next_url = self.request.POST.get('next_url',self.URLs['scriptRoot']) 279 292 salt = js_login_data.salt 280 293 context = { … … 282 295 "fallback_url": self.URLs.adminLink(""), 283 296 "salt": salt, 297 "next_url": next_url, 284 298 "PyLucid_media_url": settings.PYLUCID_MEDIA_URL, 285 299 } … … 327 341 if user: 328 342 self._login_user(user) 329 return 343 return HttpResponseRedirect(next_url) 330 344 self._insert_reset_link(context) 331 345 self.page_msg.red(msg) … … 350 364 self.page_msg("password:", password) 351 365 self.page_msg("SHA-1 - Not implemented completly, yet :(") 352 return 366 return HttpResponseRedirect(next_url) 353 367 else: 354 368 password_form = PasswordForm() … … 373 387 374 388 self.page_msg.green("You logged out.") 389 return HttpResponseRedirect(self.URLs['scriptRoot']) 375 390 376 391 #__________________________________________________________________________ -
trunk/pylucid/PyLucid/plugins_internal/auth/internal_pages/input_password.html
r1316 r1416 6 6 <input type="hidden" name="username" value="{{ username }}" /> 7 7 <input type="hidden" name="sha_login" value="little secure sha login" /> 8 <input type="hidden" name="next_url" value="{{ next_url }}" /> 8 9 9 10 <label for="plaintext_pass">{% trans 'Password' %}:</label> -
trunk/pylucid/PyLucid/plugins_internal/auth/internal_pages/input_username.html
r1180 r1416 12 12 <input type="submit" id="sha_button" name="sha_login" value="SHA-1 login" /> 13 13 <input type="submit" id="plaintext_button" name="plaintext_login" value="unsecure plaintext login" onclick="return confirm('Do you realy want to send your password in plaintext?')"/> 14 <input type="hidden" name="next_url" value="{{ next_url }}" /> 14 15 </form> 15 16 </fieldset> -
trunk/pylucid/PyLucid/plugins_internal/auth/internal_pages/plaintext_login.html
r1186 r1416 4 4 <input type="hidden" name="username" value="{{ username }}" /> 5 5 <input type="hidden" name="plaintext_login" value="unsecure plaintext login" /> 6 <input type="hidden" name="next_url" value="{{ next_url }}" /> 6 7 {{ form }} 7 8 <input type="submit" value="{% trans 'Log in' %}" /> -
trunk/pylucid/PyLucid/system/detect_page.py
r1350 r1416 18 18 19 19 from PyLucid.models import Page, Preference, Template 20 from PyLucid.system.exceptions import AccessDenied 20 21 21 22 from django.utils.translation import ugettext as _ … … 84 85 shortcuts.reverse() 85 86 wrong_shutcuts = [] 87 # FIXME: We need no for loop here, isn't it? 86 88 for shortcut in shortcuts: 87 89 try: 88 returnPage.objects.get(shortcut__exact=shortcut)90 page = Page.objects.get(shortcut__exact=shortcut) 89 91 except Page.DoesNotExist: 90 92 raise Http404(_("Page '%s' doesn't exists.") % shortcut) 93 94 if request.user.is_anonymous() and not page.permitViewPublic: 95 raise AccessDenied 96 else: 97 return page -
trunk/pylucid/PyLucid/system/exceptions.py
r1087 r1416 1 1 #!/usr/bin/python 2 # -*- coding: UTF-8 -*-2 # -*- coding: utf-8 -*- 3 3 4 4 """ … … 9 9 """ 10 10 11 class AccessDeny(Exception): 11 class AccessDenied(Exception): 12 """ 13 e.g. anonymous tries to view a cms page without permitViewPublic flag. 14 """ 12 15 pass 13 16 -
trunk/pylucid/PyLucid/system/plugin_manager.py
r1409 r1416 134 134 request.must_login = True # For static_tags an the robot tag 135 135 136 if request.user. username == "":136 if request.user.is_anonymous(): 137 137 # User is not logged in 138 138 if method_cfg.get("no_rights_error", False) == True: … … 141 141 return "" 142 142 else: 143 raise AccessDen y143 raise AccessDenied 144 144 145 145 if method_cfg["must_admin"]: 146 146 # The User must be an admin to use this method 147 147 if not (request.user.is_superuser or request.user.is_staff): 148 raise AccessDen y148 raise AccessDenied 149 149 150 150 URLs = context["URLs"]