mirror of
https://github.com/valitydev/redash.git
synced 2024-11-07 17:38:54 +00:00
Fix: create_user_and_login should accept user
This commit is contained in:
parent
823f0b8db5
commit
3014ba8eec
@ -64,22 +64,22 @@ def validate_email(email):
|
|||||||
return email in settings.ALLOWED_EXTERNAL_USERS or email.endswith("@%s" % settings.GOOGLE_APPS_DOMAIN)
|
return email in settings.ALLOWED_EXTERNAL_USERS or email.endswith("@%s" % settings.GOOGLE_APPS_DOMAIN)
|
||||||
|
|
||||||
|
|
||||||
def create_and_login_user(app, openid_user):
|
def create_and_login_user(app, user):
|
||||||
if not validate_email(openid_user.email):
|
if not validate_email(user.email):
|
||||||
return
|
return
|
||||||
|
|
||||||
try:
|
try:
|
||||||
user = models.User.get(models.User.email == openid_user.email)
|
user_object = models.User.get(models.User.email == user.email)
|
||||||
if user.name != openid_user.name:
|
if user_object.name != user.name:
|
||||||
logger.debug("Updating user name (%r -> %r)", user.name, openid_user.name)
|
logger.debug("Updating user name (%r -> %r)", user_object.name, user.name)
|
||||||
user.name = openid_user.name
|
user_object.name = user.name
|
||||||
user.save()
|
user_object.save()
|
||||||
except models.User.DoesNotExist:
|
except models.User.DoesNotExist:
|
||||||
logger.debug("Creating user object (%r)", openid_user.name)
|
logger.debug("Creating user object (%r)", user.name)
|
||||||
user = models.User.create(name=openid_user.name, email=openid_user.email,
|
user_object = models.User.create(name=user.name, email=user.email,
|
||||||
is_admin=(openid_user.email in settings.ADMINS))
|
is_admin=(user.email in settings.ADMINS))
|
||||||
|
|
||||||
login_user(user, remember=True)
|
login_user(user_object, remember=True)
|
||||||
|
|
||||||
login.connect(create_and_login_user)
|
login.connect(create_and_login_user)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user