diff rhodecode/lib/db_manage.py @ 4028:c3245a0452a3

Added --no-public-access / --public-access flags into setup-rhodecode command to enable setup without public access
author Marcin Kuzminski <marcin@python-works.com>
date Fri, 21 Jun 2013 00:36:01 +0200
parents 3648a2b2e17a
children ffd45b185016
line wrap: on
line diff
--- a/rhodecode/lib/db_manage.py	Fri Jun 21 00:01:31 2013 +0200
+++ b/rhodecode/lib/db_manage.py	Fri Jun 21 00:36:01 2013 +0200
@@ -696,10 +696,18 @@
     def create_default_user(self):
         log.info('creating default user')
         # create default user for handling default permissions.
-        UserModel().create_or_update(username='default',
-                              password=str(uuid.uuid1())[:8],
-                              email='anonymous@rhodecode.org',
-                              firstname='Anonymous', lastname='User')
+        user = UserModel().create_or_update(username=User.DEFAULT_USER,
+                                            password=str(uuid.uuid1())[:20],
+                                            email='anonymous@rhodecode.org',
+                                            firstname='Anonymous',
+                                            lastname='User')
+        # based on configuration options activate/deactive this user which
+        # controlls anonymous access
+        if self.cli_args.get('public_access') is False:
+            log.info('Public access disabled')
+            user.active = False
+            Session().add(user)
+            Session().commit()
 
     def create_permissions(self):
         """