From 745629c42c5502b69072c380944a4560ec5cc383 Mon Sep 17 00:00:00 2001 From: Kevin Doran Date: Sun, 5 Apr 2020 14:31:53 +0100 Subject: [PATCH 1/2] remove unused dep --- package.json | 1 - scripts/deploy-to-couch.js | 8 -------- 2 files changed, 9 deletions(-) diff --git a/package.json b/package.json index 8f73a3c..d8917b6 100644 --- a/package.json +++ b/package.json @@ -29,7 +29,6 @@ "babel-preset-react": "^6.24.1", "babel-preset-stage-0": "^6.24.1", "css-loader": "^0.28.10", - "prompts": "^2.0.4", "semantic-release": "^15.10.5", "standard": "^11.0.1", "style-loader": "^0.20.3", diff --git a/scripts/deploy-to-couch.js b/scripts/deploy-to-couch.js index 94bb894..5cddc4b 100644 --- a/scripts/deploy-to-couch.js +++ b/scripts/deploy-to-couch.js @@ -1,6 +1,5 @@ const fs = require('fs') const parseArgs = require('minimist') -const prompts = require('prompts') const axios = require('axios') const BUILD_PATH = './dist/' @@ -15,13 +14,6 @@ async function postDocs ({ }) { const dbUrl = `${couchUrl}${databaseName}` const docUrl = `${dbUrl}/lookout` - const {value: responseValue} = await prompts({ - type: 'confirm', - name: 'value', - message: `Did you run npm build first? Deploy to ${docUrl}?`, - initial: false - }) - if (!responseValue) return const auth = {username, password} await createDB(dbUrl, auth) const _rev = await getRev(docUrl, auth) From 75c072a992328844287dbd429098f37c13c92d41 Mon Sep 17 00:00:00 2001 From: Kevin Doran Date: Tue, 7 Apr 2020 15:22:57 +0100 Subject: [PATCH 2/2] fix: _all_dbs is authenticated 3.x --- app/app.js | 17 +++++++++++------ app/components/Login.js | 2 +- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/app/app.js b/app/app.js index d718b53..1d29bf6 100644 --- a/app/app.js +++ b/app/app.js @@ -38,17 +38,22 @@ class UserRoutes extends Component { async componentDidMount () { const { couchUrl } = this.state const { userCtx } = await fetcher.checkSession(couchUrl) - if (userCtx.name || userCtx.roles.length) { - this.onAuthenticated(userCtx) + const authenticated = userCtx.name || userCtx.roles.includes('_admin') + + if (!authenticated) { + this.setState({loading: false}) + return } - const dbs = await fetcher.get(`${couchUrl}_all_dbs`, { limit: LIMIT }) - this.setState({ loading: false, dbs }) + this.onAuthenticated(userCtx) } - onAuthenticated = (userCtx) => { + // TODO: this cache object was never used much + onAuthenticated = async (userCtx) => { + const { couchUrl } = this.state Object.assign(cache.userCtx, userCtx) - this.setState({ authenticated: true }) + const dbs = await fetcher.get(`${couchUrl}_all_dbs`, { limit: LIMIT }) + this.setState({ loading: false, dbs, authenticated: true }) } render () { diff --git a/app/components/Login.js b/app/components/Login.js index 8b7c0b4..9b287a2 100644 --- a/app/components/Login.js +++ b/app/components/Login.js @@ -26,7 +26,7 @@ export default class LoginContainer extends React.Component {
{couchUrl} change couch

- {error &&
{JSON.stringify(error, null, 2)}
}
+ {error &&
{error.message ? error.message : JSON.stringify(error, null, 2)}
}

)