Skip to content
This repository has been archived by the owner on Mar 27, 2019. It is now read-only.

Commit

Permalink
Improve Vault endpoint check (#204)
Browse files Browse the repository at this point in the history
  • Loading branch information
djenriquez authored Oct 2, 2017
1 parent 6b700e2 commit 4b49ff0
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions app/components/Login/Login.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,19 +66,18 @@ export default class Login extends React.Component {
});
} else {
this.setState({ show: true });
if (!this.state.vaultUrl) {
if (!this.state.vaultUrl || !this.state.vaultUrl.match('^http[s]*:\/\/')) {
this.setState({
openSettings: true
});
if (!this.state.vaultUrl.match('^http[s]*:\/\/'))
this.setState({ errorMessage: 'Vault URL must contain a REST protocol scheme (http:// or https://)' });
}
}
}

getVaultUrl() {
if (window.localStorage.getItem("vaultUrl"))
return window.localStorage.getItem("vaultUrl");
else
return window.defaultVaultUrl;
return window.localStorage.getItem("vaultUrl") ? window.localStorage.getItem("vaultUrl") : window.defaultVaultUrl;
}

getVaultAuthMethod() {
Expand Down Expand Up @@ -260,6 +259,9 @@ export default class Login extends React.Component {
if (!this.state.tmpVaultUrl) {
this.setState({ errorMessage: 'Please enter a Vault URL' });
}
else if (!this.state.tmpVaultUrl.match('^http[s]*:\/\/')) {
this.setState({ errorMessage: 'Vault URL must contain a REST protocol scheme (http:// or https://)' });
}
else if (!this.state.tmpLoginMethodType) {
this.setState({ errorMessage: 'Please select an authentication backend' });
} else if (!this.state.tmpAuthBackendPath) {
Expand Down

0 comments on commit 4b49ff0

Please sign in to comment.