From cf89e6b184f1699aa4bcde1574914d45e66ac9d1 Mon Sep 17 00:00:00 2001 From: jeremi Date: Tue, 24 Jun 2014 09:54:22 +0800 Subject: [PATCH] Make sure when users are created that it is with the default groups and not permissions. --- manage.py | 2 +- redash/authentication.py | 2 +- redash/models.py | 4 +++- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/manage.py b/manage.py index 820edd51..b69fb729 100755 --- a/manage.py +++ b/manage.py @@ -60,7 +60,7 @@ def drop_tables(): @users_manager.option('--admin', dest='is_admin', action="store_true", default=False, help="set user as admin") @users_manager.option('--google', dest='google_auth', action="store_true", default=False, help="user uses Google Auth to login") @users_manager.option('--password', dest='password', default=None, help="Password for users who don't use Google Auth (leave blank for prompt).") -@users_manager.option('--groups', dest='groups', default=models.Group.DEFAULT_PERMISSIONS, help="Comma seperated list of groups (leave blank for default).") +@users_manager.option('--groups', dest='groups', default=models.User.DEFAULT_GROUPS, help="Comma seperated list of groups (leave blank for default).") def create(email, name, groups, is_admin=False, google_auth=False, password=None): print "Creating user (%s, %s)..." % (email, name) print "Admin: %r" % is_admin diff --git a/redash/authentication.py b/redash/authentication.py index df75b267..bc0ec6ff 100644 --- a/redash/authentication.py +++ b/redash/authentication.py @@ -76,7 +76,7 @@ def create_and_login_user(app, user): user_object.save() except models.User.DoesNotExist: logger.debug("Creating user object (%r)", user.name) - user_object = models.User.create(name=user.name, email=user.email, groups = ['default']) + user_object = models.User.create(name=user.name, email=user.email, groups = models.User.DEFAULT_GROUPS) login_user(user_object, remember=True) diff --git a/redash/models.py b/redash/models.py index 423c50a3..2f587a5f 100644 --- a/redash/models.py +++ b/redash/models.py @@ -102,11 +102,13 @@ class Group(BaseModel): class User(BaseModel, UserMixin): + DEFAULT_GROUPS = ['default'] + id = peewee.PrimaryKeyField() name = peewee.CharField(max_length=320) email = peewee.CharField(max_length=320, index=True, unique=True) password_hash = peewee.CharField(max_length=128, null=True) - groups = ArrayField(peewee.CharField, default=['default']) + groups = ArrayField(peewee.CharField, default=DEFAULT_GROUPS) class Meta: db_table = 'users'