Skip to content

Commit

Permalink
Merge pull request #670 from auth0/default_directory
Browse files Browse the repository at this point in the history
lock by default should show the default_directory from tenant info
  • Loading branch information
hzalaz authored Oct 24, 2016
2 parents cea40e7 + 5244be7 commit 7e63ffb
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 2 deletions.
5 changes: 4 additions & 1 deletion src/connection/database/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
import { dataFns } from '../../utils/data_utils';
import sync from '../../sync';
import trim from 'trim';
import { defaultDirectory } from '../../core/tenant';

const { get, initNS, tget, tset } = dataFns(["database"]);

Expand Down Expand Up @@ -224,7 +225,9 @@ export function defaultDatabaseConnectionName(m) {
}

export function databaseConnection(m) {
return defaultDatabaseConnection(m) || l.connection(m, "database");
return defaultDirectory(m) ||
defaultDatabaseConnection(m) ||
l.connection(m, "database");
}

export function databaseConnectionName(m) {
Expand Down
13 changes: 12 additions & 1 deletion src/core/tenant/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import Immutable, { List, Map } from 'immutable';
import { dataFns } from '../../utils/data_utils';
import * as l from '../index';

const { initNS, get } = dataFns(["client"]);

Expand Down Expand Up @@ -39,7 +40,8 @@ export function initTenant(m, client_id, client) {

function formatTenant(client_id, o) {
return new Immutable.fromJS({
connections: formatTenantConnections(client_id, o)
connections: formatTenantConnections(client_id, o),
default_directory: o.default_directory || null
})
}

Expand Down Expand Up @@ -94,3 +96,12 @@ function formatTenantConnection(connectionType, connection) {
export function tenantConnections(m) {
return get(m, "connections", emptyConnections);
}

export function defaultDirectory(m) {
const name = defaultDirectoryName(m);
return name && l.findConnection(m, name);
}

export function defaultDirectoryName(m) {
return get(m, "default_directory", null);
}
5 changes: 5 additions & 0 deletions src/engine/classic.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import {
isInCorpNetwork,
quickAuthConnection
} from '../connection/enterprise';
import { defaultDirectory, defaultDirectoryName } from '../core/tenant';
import { initSocial, useBigButtons } from '../connection/social/index';
import { setEmail } from '../field/email';
import { setUsername } from '../field/username';
Expand Down Expand Up @@ -77,6 +78,10 @@ function validateAllowedConnections(m) {
m = l.stop(m, error);
}

if (defaultDirectoryName(m) && !defaultDirectory(m)) {
l.error(m, `The account's default directory "${defaultDirectoryName(m)}" is not enabled.`);
}

if (defaultDatabaseConnectionName(m) && !defaultDatabaseConnection(m)) {
l.warn(m, `The provided default database connection "${defaultDatabaseConnectionName(m)}" is not enabled.`);
}
Expand Down

0 comments on commit 7e63ffb

Please sign in to comment.