Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Updated georegistry to latest pylons-authentication
- Loading branch information
1 parent
3744aa8
commit aaa1415
Showing
20 changed files
with
219 additions
and
249 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -1,4 +1,4 @@ | |||
.development.cfg | |||
.production.cfg | |||
*.pyc | |||
data | data | ||
production.ini | |||
*.pyc | |||
*.swp |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,47 @@ | |||
# | |||
# georegistry - Pylons configuration | |||
# | |||
# The %(here)s variable will be replaced with the parent directory of this file | |||
# | |||
[DEFAULT] | |||
debug = false | |||
email_to = | |||
error_email_from = support@example.com | |||
smtp_server = localhost | |||
# smtp_username = | |||
# smtp_password = | |||
# smtp_use_tls = True | |||
|
|||
[server:main] | |||
use = egg:Paste#http | |||
host = 0.0.0.0 | |||
port = 5000 | |||
|
|||
[app:main] | |||
use = egg:georegistry | |||
full_stack = true | |||
static_files = true | |||
cache_dir = %(here)s/data | |||
app_instance_uuid = ${app_instance_uuid} | |||
beaker.session.key = georegistry | |||
beaker.session.secret = ${app_instance_secret} | |||
sqlalchemy.url = sqlite:///production.db | |||
# recaptcha.public = | |||
# recaptcha.private = | |||
|
|||
[loggers] | |||
keys = root | |||
[handlers] | |||
keys = console | |||
[formatters] | |||
keys = generic | |||
[logger_root] | |||
level = WARN | |||
handlers = console | |||
[handler_console] | |||
class = StreamHandler | |||
args = (sys.stderr,) | |||
level = NOTSET | |||
formatter = generic | |||
[formatter_generic] | |||
format = %(asctime)s %(levelname)-5.5s [%(name)s] [%(threadName)s] %(message)s |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,50 @@ | |||
'General decorators' | |||
# Import pylons modules | |||
from pylons import request, url | |||
from pylons.controllers.util import redirect | |||
# Import system modules | |||
from decorator import decorator | |||
# Import custom modules | |||
from georegistry.lib import helpers as h | |||
|
|||
|
|||
# Authentication | |||
|
|||
@decorator | |||
def requireLogin(func, *args, **kwargs): | |||
'Redirect to login if the user is not logged in' | |||
# If the user is not logged in, | |||
if not h.isPerson(): | |||
return redirect(url('person_login', targetURL=h.encodeURL(request.path))) | |||
# Execute | |||
return func(*args, **kwargs) | |||
|
|||
@decorator | |||
def requireLoginJSON(func, *args, **kwargs): | |||
'Give error message if the user is not logged in' | |||
# If the user is not logged in, | |||
if not h.isPerson(): | |||
return dict(isOk=0, message='Login required') | |||
# Execute | |||
return func(*args, **kwargs) | |||
|
|||
|
|||
# Authorization | |||
|
|||
@decorator | |||
def requireSuper(func, *args, **kwargs): | |||
'Redirect to homepage if the user is not a superuser' | |||
# If the user is not a superuser, | |||
if not h.isPersonSuper(): | |||
return redirect(url('person_login', targetURL=h.encodeURL('/'))) | |||
# Execute | |||
return func(*args, **kwargs) | |||
|
|||
@decorator | |||
def requireSuperJSON(func, *args, **kwargs): | |||
'Give error message if the user is not a superuser' | |||
# If the user is not a superuser, | |||
if not h.isPersonSuper(): | |||
return dict(isOk=0, message='Access denied') | |||
# Execute | |||
return func(*args, **kwargs) |
Oops, something went wrong.