[Update] 修改一些bug

pull/2530/head^2
ibuler 2019-03-22 15:18:47 +08:00
parent 311538dcf8
commit c82044f6bc
4 changed files with 17 additions and 7 deletions

View File

@ -88,7 +88,10 @@ class LDAPUser(_LDAPUser):
def _populate_user_from_attributes(self): def _populate_user_from_attributes(self):
super()._populate_user_from_attributes() super()._populate_user_from_attributes()
if not hasattr(self._user, 'email') or '@' not in self._user.email: if not hasattr(self._user, 'email') or '@' not in self._user.email:
email = '{}@{}'.format(self._user.username, settings.EMAIL_SUFFIX) if '@' not in self._user.username:
email = '{}@{}'.format(self._user.username, settings.EMAIL_SUFFIX)
else:
email = self._user.username
setattr(self._user, 'email', email) setattr(self._user, 'email', email)

View File

@ -193,7 +193,7 @@ class Config(dict):
if self.root_path: if self.root_path:
filename = os.path.join(self.root_path, filename) filename = os.path.join(self.root_path, filename)
try: try:
with open(filename) as f: with open(filename, 'rt', encoding='utf8') as f:
obj = yaml.load(f) obj = yaml.load(f)
except IOError as e: except IOError as e:
if silent and e.errno in (errno.ENOENT, errno.EISDIR): if silent and e.errno in (errno.ENOENT, errno.EISDIR):

View File

@ -6,12 +6,15 @@ from celery import Celery
# set the default Django settings module for the 'celery' program. # set the default Django settings module for the 'celery' program.
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'jumpserver.settings') os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'jumpserver.settings')
from jumpserver import settings
from django.conf import settings # from django.conf import settings
app = Celery('jumpserver') app = Celery('jumpserver')
configs = {k: v for k, v in settings.__dict__.items() if k.startswith('CELERY')}
# Using a string here means the worker will not have to # Using a string here means the worker will not have to
# pickle the object when using Windows. # pickle the object when using Windows.
app.config_from_object('django.conf:settings', namespace='CELERY') # app.config_from_object('django.conf:settings', namespace='CELERY')
app.namespace = 'CELERY'
app.conf.update(configs)
app.autodiscover_tasks(lambda: [app_config.split('.')[0] for app_config in settings.INSTALLED_APPS]) app.autodiscover_tasks(lambda: [app_config.split('.')[0] for app_config in settings.INSTALLED_APPS])

View File

@ -14,8 +14,12 @@ class SwitchOrgView(DetailView):
pk = kwargs.get('pk') pk = kwargs.get('pk')
self.object = Organization.get_instance(pk) self.object = Organization.get_instance(pk)
request.session['oid'] = self.object.id.__str__() request.session['oid'] = self.object.id.__str__()
referer = request.META.get('HTTP_REFERER', reverse('index')) host = request.get_host()
return redirect(referer) referer = request.META.get('HTTP_REFERER')
if referer.find(host) != -1:
return redirect(referer)
else:
return redirect('index')
class SwitchToAOrgView(View): class SwitchToAOrgView(View):