aboutsummaryrefslogtreecommitdiffstats
path: root/mediagoblin/auth
diff options
context:
space:
mode:
authorRodney Ewing <ewing.rj@gmail.com>2013-05-28 09:20:35 -0700
committerRodney Ewing <ewing.rj@gmail.com>2013-05-28 09:20:35 -0700
commitbd7fe0c25279541f93ccb71fe0261ebcd4e8d056 (patch)
tree4434d00adad8da60249ee5f7afc294303e63474f /mediagoblin/auth
parentb85d9e9567984578ba549165edf721d67a83fa66 (diff)
parentf9e032212dff4d54de644cb5537bc0bef6d24c7f (diff)
downloadmediagoblin-bd7fe0c25279541f93ccb71fe0261ebcd4e8d056.tar.lz
mediagoblin-bd7fe0c25279541f93ccb71fe0261ebcd4e8d056.tar.xz
mediagoblin-bd7fe0c25279541f93ccb71fe0261ebcd4e8d056.zip
Merge remote-tracking branch 'upstream/master' into basic_auth
Conflicts: mediagoblin/auth/tools.py mediagoblin/auth/views.py mediagoblin/plugins/basic_auth/tools.py
Diffstat (limited to 'mediagoblin/auth')
-rw-r--r--mediagoblin/auth/tools.py58
-rw-r--r--mediagoblin/auth/views.py14
2 files changed, 30 insertions, 42 deletions
diff --git a/mediagoblin/auth/tools.py b/mediagoblin/auth/tools.py
index 40dcf59e..adcf07fe 100644
--- a/mediagoblin/auth/tools.py
+++ b/mediagoblin/auth/tools.py
@@ -59,35 +59,6 @@ def normalize_user_or_email_field(allow_email=True, allow_user=True):
return _normalize_field
-class AuthError(Exception):
- def __init__(self):
- self.value = 'No Authentication Plugin is enabled and no_auth = false'\
- ' in config!'
-
- def __str__(self):
- return repr(self.value)
-
-
-def check_auth_enabled():
- no_auth = mg_globals.app_config['no_auth']
- auth_plugin = hook_handle('authentication')
-
- if no_auth == 'false' and not auth_plugin:
- raise AuthError
-
- if no_auth == 'true' and not auth_plugin:
- _log.warning('No authentication is enabled')
- return False
- else:
- return True
-
-
-def no_auth_logout(request):
- """Log out the user if in no_auth mode"""
- if not mg_globals.app.auth:
- request.session.delete()
-
-
EMAIL_VERIFICATION_TEMPLATE = (
u"http://{host}{uri}?"
u"userid={userid}&token={verification_key}")
@@ -205,3 +176,32 @@ def check_login_simple(username, password):
return None
_log.info("Logging %r in", username)
return user
+
+
+class AuthError(Exception):
+ def __init__(self):
+ self.value = 'No Authentication Plugin is enabled and no_auth = false'\
+ ' in config!'
+
+ def __str__(self):
+ return repr(self.value)
+
+
+def check_auth_enabled():
+ no_auth = mg_globals.app_config['no_auth']
+ auth_plugin = hook_handle('authentication')
+
+ if no_auth == 'false' and not auth_plugin:
+ raise AuthError
+
+ if no_auth == 'true' and not auth_plugin:
+ _log.warning('No authentication is enabled')
+ return False
+ else:
+ return True
+
+
+def no_auth_logout(request):
+ """Log out the user if in no_auth mode"""
+ if not mg_globals.app.auth:
+ request.session.delete()
diff --git a/mediagoblin/auth/views.py b/mediagoblin/auth/views.py
index d2220cb7..fa84bbb1 100644
--- a/mediagoblin/auth/views.py
+++ b/mediagoblin/auth/views.py
@@ -22,20 +22,11 @@ from mediagoblin.db.models import User
from mediagoblin.tools.response import render_to_response, redirect, render_404
from mediagoblin.tools.translate import pass_to_ugettext as _
from mediagoblin.tools.mail import email_debug_message
-<<<<<<< HEAD
from mediagoblin.auth import forms as auth_forms
-from mediagoblin.auth.tools import (send_verification_email,
- register_user,
+from mediagoblin.auth.tools import (send_verification_email, register_user,
send_fp_verification_email,
check_login_simple)
from mediagoblin import auth
-=======
-from mediagoblin.auth import lib as auth_lib
-from mediagoblin.auth import forms as auth_forms
-from mediagoblin.auth.lib import send_fp_verification_email
-from mediagoblin.auth.tools import (send_verification_email, register_user,
- check_login_simple)
->>>>>>> upstream/master
def register(request):
@@ -101,18 +92,15 @@ def login(request):
login_failed = False
if request.method == 'POST':
-<<<<<<< HEAD
username = login_form.username.data
if login_form.validate():
user = check_login_simple(username, login_form.password.data)
-=======
username = login_form.data['username']
if login_form.validate():
user = check_login_simple(username, login_form.password.data, True)
->>>>>>> upstream/master
if user:
# set up login in session