mirror of
https://github.com/getredash/redash.git
synced 2026-03-24 11:00:27 -04:00
Change: redirect to / when org not found
This commit is contained in:
@@ -16,7 +16,9 @@ logger = logging.getLogger('authentication')
|
||||
|
||||
|
||||
def get_login_url(external=False, next="/"):
|
||||
if settings.MULTI_ORG:
|
||||
if settings.MULTI_ORG and current_org == None:
|
||||
login_url = '/'
|
||||
elif settings.MULTI_ORG:
|
||||
login_url = url_for('redash.login', org_slug=current_org.slug, next=next, _external=external)
|
||||
else:
|
||||
login_url = url_for('redash.login', next=next, _external=external)
|
||||
@@ -155,5 +157,3 @@ def setup_authentication(app):
|
||||
else:
|
||||
logger.warning("Unknown authentication type ({}). Using default (HMAC).".format(settings.AUTH_TYPE))
|
||||
login_manager.request_loader(hmac_load_user_from_request)
|
||||
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ single Organization in your installation.
|
||||
|
||||
import logging
|
||||
|
||||
from flask import request, g
|
||||
from flask import g, request
|
||||
from werkzeug.local import LocalProxy
|
||||
|
||||
from redash.models import Organization
|
||||
|
||||
@@ -2,12 +2,14 @@ import time
|
||||
|
||||
from flask import request
|
||||
from mock import patch
|
||||
from redash import models
|
||||
from tests import BaseTestCase
|
||||
|
||||
from redash import models, settings
|
||||
from redash.authentication import (api_key_load_user_from_request,
|
||||
hmac_load_user_from_request, sign)
|
||||
get_login_url, hmac_load_user_from_request,
|
||||
sign)
|
||||
from redash.authentication.google_oauth import (create_and_login_user,
|
||||
verify_profile)
|
||||
from tests import BaseTestCase
|
||||
|
||||
|
||||
class TestApiKeyAuthentication(BaseTestCase):
|
||||
@@ -169,3 +171,13 @@ class TestVerifyProfile(BaseTestCase):
|
||||
self.factory.create_user(email='arik@example.com')
|
||||
self.factory.org.settings[models.Organization.SETTING_GOOGLE_APPS_DOMAINS] = ['example.org']
|
||||
self.assertTrue(verify_profile(self.factory.org, profile))
|
||||
|
||||
|
||||
class TestGetLoginUrl(BaseTestCase):
|
||||
def test_when_multi_org_enabled_and_org_exists(self):
|
||||
with self.app.test_request_context('/{}/'.format(self.factory.org.slug)):
|
||||
self.assertEqual(get_login_url(next=None), '/{}/login'.format(self.factory.org.slug))
|
||||
|
||||
def test_when_multi_org_enabled_and_org_doesnt_exist(self):
|
||||
with self.app.test_request_context('/{}_notexists/'.format(self.factory.org.slug)):
|
||||
self.assertEqual(get_login_url(next=None), '/')
|
||||
|
||||
Reference in New Issue
Block a user