Merge remote-tracking branch 'upstream/master' into basic_auth
authorRodney Ewing <ewing.rj@gmail.com>
Tue, 28 May 2013 16:20:35 +0000 (09:20 -0700)
committerRodney Ewing <ewing.rj@gmail.com>
Tue, 28 May 2013 16:20:35 +0000 (09:20 -0700)
Conflicts:
mediagoblin/auth/tools.py
mediagoblin/auth/views.py
mediagoblin/plugins/basic_auth/tools.py

1  2 
mediagoblin/auth/tools.py
mediagoblin/auth/views.py

index 40dcf59eab61ac3fc4704b3e8b0c11ff2a289e61,db6b6e3708c88a50b0c06dac2eb0db2c633d8dc4..adcf07fe0689aa56ebe5d96c5f1906738babca84
@@@ -205,3 -157,3 +176,32 @@@ def check_login_simple(username, passwo
          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()
index d2220cb71220f1b6ee851e2373df4588c8039e60,bb7bda7759f632e0bbb76d8da34368214d95112f..fa84bbb178f36520849efd689491c8f59b280df4
@@@ -22,20 -22,11 +22,11 @@@ from mediagoblin.db.models import Use
  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 lib as auth_lib
  from mediagoblin.auth import forms as auth_forms
- from mediagoblin.auth.tools import (send_verification_email,
-                                     register_user,
 -from mediagoblin.auth.lib import send_fp_verification_email
+ from mediagoblin.auth.tools import (send_verification_email, register_user,
 +                                    send_fp_verification_email,
                                      check_login_simple)
- =======
- 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
 +from mediagoblin import auth
  
  
  def register(request):
@@@ -101,12 -73,6 +92,10 @@@ 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']