Changeset - ff6a8196ebfe
[Not reviewed]
beta
0 2 0
Marcin Kuzminski - 15 years ago 2010-11-13 02:50:32
marcin@python-works.com
fixed anonymous access bug.
2 files changed with 6 insertions and 2 deletions:
0 comments (0 inline, 0 general)
rhodecode/lib/auth.py
Show inline comments
 
@@ -206,22 +206,21 @@ def fill_perms(user):
 
def get_user(session):
 
    """
 
    Gets user from session, and wraps permissions into user
 
    :param session:
 
    """
 
    user = session.get('rhodecode_user', AuthUser())
 

	
 

	
 
    #if the user is not logged in we check for anonymous access
 
    #if user is logged and it's a default user check if we still have anonymous
 
    #access enabled
 
    if user.user_id is None or user.username == 'default':
 
        anonymous_user = UserModel().get_by_username('default', cache=True)
 
        if anonymous_user.active is True:
 
            #then we set this user is logged in
 
            user.is_authenticated = True
 
            user.user_id = anonymous_user.user_id
 
        else:
 
            user.is_authenticated = False
 

	
 
    if user.is_authenticated:
 
        user = UserModel().fill_data(user)
 

	
rhodecode/model/user.py
Show inline comments
 
@@ -148,12 +148,17 @@ class UserModel(object):
 
    def fill_data(self, user):
 
        """
 
        Fills user data with those from database and log out user if not 
 
        present in database
 
        :param user:
 
        """
 

	
 
        if not hasattr(user, 'user_id') or user.user_id is None:
 
            raise Exception('passed in user has to have the user_id attribute')
 

	
 

	
 
        log.debug('filling auth user data')
 
        try:
 
            dbuser = self.get(user.user_id)
 
            user.username = dbuser.username
 
            user.is_admin = dbuser.admin
 
            user.name = dbuser.name
0 comments (0 inline, 0 general)