Changeset - 7b780f5f5cab
[Not reviewed]
default
0 1 0
Søren Løvborg - 10 years ago 2015-08-24 16:50:43
sorenl@unity3d.com
auth: avoid random auth_internal failures - add explicit import of auth_internal to user admin

auth_internal would often have been loaded by the custom auth module loader and
available as auth_modules.auth_internal ... but sometimes it wasn't and
navigating to Add User would fail with:

File '.../kallithea/controllers/admin/users.py', line 155 in new
c.default_extern_type = auth_modules.auth_internal.KallitheaAuthPlugin.name
AttributeError: 'module' object has no attribute 'auth_internal'
1 file changed with 5 insertions and 4 deletions:
0 comments (0 inline, 0 general)
kallithea/controllers/admin/users.py
Show inline comments
 
@@ -40,12 +40,13 @@ import kallithea
 
from kallithea.lib.exceptions import DefaultUserException, \
 
    UserOwnsReposException, UserCreationError
 
from kallithea.lib import helpers as h
 
from kallithea.lib.auth import LoginRequired, HasPermissionAllDecorator, \
 
    AuthUser
 
from kallithea.lib import auth_modules
 
from kallithea.lib.auth_modules import auth_internal
 
from kallithea.lib.base import BaseController, render
 
from kallithea.model.api_key import ApiKeyModel
 

	
 
from kallithea.model.db import User, UserEmailMap, UserIpMap, UserToPerm
 
from kallithea.model.forms import UserForm, CustomDefaultPermissionsForm
 
from kallithea.model.user import UserModel
 
@@ -117,14 +118,14 @@ class UsersController(BaseController):
 

	
 
        return render('admin/users/users.html')
 

	
 
    def create(self):
 
        """POST /users: Create a new item"""
 
        # url('users')
 
        c.default_extern_type = auth_modules.auth_internal.KallitheaAuthPlugin.name
 
        c.default_extern_name = auth_modules.auth_internal.KallitheaAuthPlugin.name
 
        c.default_extern_type = auth_internal.KallitheaAuthPlugin.name
 
        c.default_extern_name = auth_internal.KallitheaAuthPlugin.name
 
        user_model = UserModel()
 
        user_form = UserForm()()
 
        try:
 
            form_result = user_form.to_python(dict(request.POST))
 
            user = user_model.create(form_result)
 
            usr = form_result['username']
 
@@ -149,14 +150,14 @@ class UsersController(BaseController):
 
                    % request.POST.get('username'), category='error')
 
        return redirect(url('users'))
 

	
 
    def new(self, format='html'):
 
        """GET /users/new: Form to create a new item"""
 
        # url('new_user')
 
        c.default_extern_type = auth_modules.auth_internal.KallitheaAuthPlugin.name
 
        c.default_extern_name = auth_modules.auth_internal.KallitheaAuthPlugin.name
 
        c.default_extern_type = auth_internal.KallitheaAuthPlugin.name
 
        c.default_extern_name = auth_internal.KallitheaAuthPlugin.name
 
        return render('admin/users/user_add.html')
 

	
 
    def update(self, id):
 
        """PUT /users/id: Update an existing item"""
 
        # Forms posted to this method should contain a hidden field:
 
        #    <input type="hidden" name="_method" value="PUT" />
0 comments (0 inline, 0 general)