| LEFT | RIGHT |
| 1 # Copyright 2008 Google Inc. | 1 # Copyright 2008 Google Inc. |
| 2 # | 2 # |
| 3 # Licensed under the Apache License, Version 2.0 (the "License"); | 3 # Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 # you may not use this file except in compliance with the License. | 4 # you may not use this file except in compliance with the License. |
| 5 # You may obtain a copy of the License at | 5 # You may obtain a copy of the License at |
| 6 # | 6 # |
| 7 # http://www.apache.org/licenses/LICENSE-2.0 | 7 # http://www.apache.org/licenses/LICENSE-2.0 |
| 8 # | 8 # |
| 9 # Unless required by applicable law or agreed to in writing, software | 9 # Unless required by applicable law or agreed to in writing, software |
| 10 # distributed under the License is distributed on an "AS IS" BASIS, | 10 # distributed under the License is distributed on an "AS IS" BASIS, |
| 11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | 11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 # See the License for the specific language governing permissions and | 12 # See the License for the specific language governing permissions and |
| 13 # limitations under the License. | 13 # limitations under the License. |
| 14 | 14 |
| 15 """ | 15 """ |
| 16 Authentication module that mimics the behavior of Django's authentication | 16 Authentication module that mimics the behavior of Django's authentication |
| 17 implementation. | 17 implementation. |
| 18 | 18 |
| 19 Limitations: | 19 Limitations: |
| 20 - all user permissions methods are not available | 20 - all user permissions methods are not available |
| 21 """ | 21 """ |
| 22 | 22 |
| 23 from datetime import datetime | 23 from datetime import datetime |
| 24 import urllib | 24 import urllib |
| 25 | 25 |
| 26 from django.db.models.manager import EmptyManager |
| 26 from django.http import HttpResponseRedirect | 27 from django.http import HttpResponseRedirect |
| 27 from django.template import Node | 28 from django.template import Node |
| 29 from django.utils.encoding import smart_str |
| 28 | 30 |
| 29 from google.appengine.api import datastore_types | 31 from google.appengine.api import datastore_types |
| 30 from google.appengine.api import users | 32 from google.appengine.api import users |
| 31 from google.appengine.ext.db import UserProperty | 33 from google.appengine.ext.db import UserProperty |
| 32 from google.appengine.ext.webapp import template | 34 from google.appengine.ext.webapp import template |
| 33 | 35 |
| 34 from appengine_django import models | 36 from appengine_django import models |
| 35 | 37 |
| 36 register = template.create_template_register() | 38 register = template.create_template_register() |
| 37 template.register_template_library("appengine_django.auth") | 39 template.register_template_library("appengine_django.auth") |
| (...skipping 37 matching lines...) Show 10 above Show 10 below |
| 75 """ | 77 """ |
| 76 bits = list(token.split_contents()) | 78 bits = list(token.split_contents()) |
| 77 if len(bits) == 2: | 79 if len(bits) == 2: |
| 78 redirect = bits[1] | 80 redirect = bits[1] |
| 79 else: | 81 else: |
| 80 redirect = "/" | 82 redirect = "/" |
| 81 login = bits[0] == "auth_login_url" | 83 login = bits[0] == "auth_login_url" |
| 82 return AuthLoginUrlsNode(login, redirect) | 84 return AuthLoginUrlsNode(login, redirect) |
| 83 register.tag("auth_login_url", auth_login_urls) | 85 register.tag("auth_login_url", auth_login_urls) |
| 84 register.tag("auth_logout_url", auth_login_urls) | 86 register.tag("auth_logout_url", auth_login_urls) |
| LEFT | RIGHT |