Skip to content

Commit

Permalink
Update messages on migth require auth
Browse files Browse the repository at this point in the history
  • Loading branch information
OskarDamkjaer committed Nov 4, 2020
1 parent ee8e02e commit 5aec922
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 11 deletions.
6 changes: 3 additions & 3 deletions src/browser/modules/Stream/Auth/ConnectForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -111,18 +111,18 @@ export default function ConnectForm(props: ConnectFormProps): JSX.Element {
hasSecureSchemes ? '+s' : ''
}:// for a direct connection to a DBMS instance.`

const multipleSchemesAllowed = props.allowedSchemes.length > 1
const schemeRestriction = props.allowedSchemes.length > 0

return (
<StyledConnectionForm onSubmit={onConnectClick}>
<StyledConnectionFormEntry>
<StyledConnectionLabel
htmlFor="url-input"
title={multipleSchemesAllowed ? hoverText : ''}
title={schemeRestriction ? hoverText : ''}
>
Connect URL
</StyledConnectionLabel>
{multipleSchemesAllowed ? (
{schemeRestriction ? (
<>
<StyledSegment>
<StyledConnectionSelect
Expand Down
8 changes: 6 additions & 2 deletions src/browser/modules/Stream/Auth/ConnectionForm.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,11 @@ import { NATIVE, NO_AUTH } from 'services/bolt/boltHelpers'
import ConnectForm from './ConnectForm'
import ConnectedView from './ConnectedView'
import ChangePasswordForm from './ChangePasswordForm'
import { getAllowedBoltSchemes, inCloudEnv } from 'shared/modules/app/appDuck'
import {
getAllowedAuthSchemes,
getAllowedBoltSchemes,
inCloudEnv
} from 'shared/modules/app/appDuck'
import { FOCUS } from 'shared/modules/editor/editorDuck'
import {
generateBoltUrl,
Expand Down Expand Up @@ -336,7 +340,7 @@ const mapStateToProps = state => {
storeCredentials: shouldRetainConnectionCredentials(state),
isConnected: isConnected(state),
allowedSchemes: getAllowedBoltSchemes(state),
allowedAuthMethods: inCloudEnv(state) ? [NATIVE] : [NATIVE, NO_AUTH]
allowedAuthMethods: getAllowedAuthSchemes(state)
}
}

Expand Down
13 changes: 8 additions & 5 deletions src/browser/modules/Stream/Auth/ConnectionFrame.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ import { Lead } from 'browser-components/Text'
import Render from 'browser-components/Render'
import { StyledConnectionAside, StyledConnectionBodyContainer } from './styled'
import { connect } from 'react-redux'
import { inCloudEnv } from 'shared/modules/app/appDuck'
import { getAllowedAuthSchemes } from 'shared/modules/app/appDuck'
import { NO_AUTH } from 'services/bolt/boltHelpers'

export class ConnectionFrame extends Component {
constructor(props) {
Expand Down Expand Up @@ -69,9 +70,11 @@ export class ConnectionFrame extends Component {
<>
<H3>Connect to Neo4j</H3>
<Lead>
{this.props.inCloudEnv
? 'Database access on Neo4j Aura requires an authenticated connection'
: 'Database access might require an authenticated connection.'}
Database access
{this.props.mightRequireAuth
? ' might require '
: ' requires '}
an authenticated connection
</Lead>
</>
)}
Expand All @@ -92,7 +95,7 @@ export class ConnectionFrame extends Component {

const mapStateToProps = state => {
return {
inCloudEnv: inCloudEnv(state)
mightRequireAuth: getAllowedAuthSchemes(state).includes(NO_AUTH)
}
}

Expand Down
7 changes: 6 additions & 1 deletion src/shared/modules/app/appDuck.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

import { NATIVE, NO_AUTH } from 'services/bolt/boltHelpers'

// Action type constants
export const NAME = 'app'
export const APP_START = `${NAME}/APP_START`
Expand All @@ -35,12 +37,15 @@ const INSECURE_SCHEMES = ['neo4j', 'bolt']

// Selectors
export const getHostedUrl = state => (state[NAME] || {}).hostedUrl || null
export const getEnv = state => (state[NAME] || {}).env || WEB
export const getEnv = state => CLOUD //(state[NAME] || {}).env || WEB
export const hasDiscoveryEndpoint = state =>
[WEB, CLOUD].includes(getEnv(state))
export const inWebEnv = state => getEnv(state) === WEB
export const inCloudEnv = state => getEnv(state) === CLOUD
export const inWebBrowser = state => [WEB, CLOUD].includes(getEnv(state))
export const getAllowedAuthSchemes = state =>
inCloudEnv(state) ? [] : [NATIVE, NO_AUTH]

export const getAllowedBoltSchemes = (state, encryptionFlag) => {
if (inCloudEnv(state) /* Aura only allows neo4j+s */) {
return ['neo4j+s']
Expand Down

0 comments on commit 5aec922

Please sign in to comment.