changeset 2634:4b17216f2110 beta

Deprecated validation of operating system, we just care if it's windows, let approve all other systems. - help to supports cases like cygwin etc - fixed typo in auth decorator
author Marcin Kuzminski <marcin@python-works.com>
date Fri, 20 Jul 2012 12:05:32 +0200
parents bc272fd65e57
children d6fa7805e687
files rhodecode/__init__.py rhodecode/lib/auth.py
diffstat 2 files changed, 10 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/rhodecode/__init__.py	Fri Jul 20 12:00:57 2012 +0200
+++ b/rhodecode/__init__.py	Fri Jul 20 12:05:32 2012 +0200
@@ -46,10 +46,10 @@
 __url__ = 'http://rhodecode.org'
 
 PLATFORM_WIN = ('Windows')
-PLATFORM_OTHERS = ('Linux', 'Darwin', 'FreeBSD', 'OpenBSD', 'SunOS')
+PLATFORM_OTHERS = ('Linux', 'Darwin', 'FreeBSD', 'OpenBSD', 'SunOS') #depracated
 
 is_windows = __platform__ in PLATFORM_WIN
-is_unix = __platform__ in PLATFORM_OTHERS
+is_unix = not is_windows
 
 
 BACKENDS = {
--- a/rhodecode/lib/auth.py	Fri Jul 20 12:00:57 2012 +0200
+++ b/rhodecode/lib/auth.py	Fri Jul 20 12:05:32 2012 +0200
@@ -35,7 +35,7 @@
 from pylons.controllers.util import abort, redirect
 from pylons.i18n.translation import _
 
-from rhodecode import __platform__, PLATFORM_WIN, PLATFORM_OTHERS
+from rhodecode import __platform__, is_windows, is_unix
 from rhodecode.model.meta import Session
 
 from rhodecode.lib.utils2 import str2bool, safe_unicode
@@ -92,10 +92,10 @@
 
         :param password: password to hash
         """
-        if __platform__ in PLATFORM_WIN:
+        if is_windows:
             from hashlib import sha256
             return sha256(str_).hexdigest()
-        elif __platform__ in PLATFORM_OTHERS:
+        elif is_unix:
             import bcrypt
             return bcrypt.hashpw(str_, bcrypt.gensalt(10))
         else:
@@ -112,10 +112,10 @@
         :param hashed: password in hashed form
         """
 
-        if __platform__ in PLATFORM_WIN:
+        if is_windows:
             from hashlib import sha256
             return sha256(password).hexdigest() == hashed
-        elif __platform__ in PLATFORM_OTHERS:
+        elif is_unix:
             import bcrypt
             return bcrypt.hashpw(password, hashed) == hashed
         else:
@@ -235,7 +235,7 @@
                                           user_attrs):
                     log.info('created new ldap user %s' % username)
 
-                Session.commit()
+                Session().commit()
                 return True
             except (LdapUsernameError, LdapPasswordError,):
                 pass
@@ -262,7 +262,7 @@
         return None
 
     user.update_lastlogin()
-    Session.commit()
+    Session().commit()
 
     log.debug('User %s is now logged in by container authentication',
               user.username)
@@ -768,7 +768,7 @@
 class HasReposGroupPermissionAll(PermsFunction):
     def __call__(self, group_name=None, check_Location=''):
         self.group_name = group_name
-        return super(HasReposGroupPermissionAny, self).__call__(check_Location)
+        return super(HasReposGroupPermissionAll, self).__call__(check_Location)
 
     def check_permissions(self):
         try: