diff --git a/ui/package.json b/ui/package.json index 1142f61a33..0414e187e0 100644 --- a/ui/package.json +++ b/ui/package.json @@ -81,7 +81,7 @@ "devDependencies": { "@babel/core": "^7.5.5", "@babel/preset-env": "^7.5.5", - "@chnn/oats": "0.2.1", + "@chnn/oats": "0.3.0", "@cypress/webpack-preprocessor": "^4.0.3", "@types/chroma-js": "^1.3.4", "@types/codemirror": "^0.0.56", diff --git a/ui/src/Logout.tsx b/ui/src/Logout.tsx index b2aeffcc23..3cd194a60f 100644 --- a/ui/src/Logout.tsx +++ b/ui/src/Logout.tsx @@ -3,7 +3,7 @@ import {PureComponent} from 'react' import {withRouter, WithRouterProps} from 'react-router' // APIs -import {client} from 'src/utils/api' +import {postSignout} from 'src/client' // Constants import {CLOUD, CLOUD_SIGNOUT_URL} from 'src/shared/constants' @@ -28,7 +28,12 @@ export class Logout extends PureComponent { window.location.href = CLOUD_SIGNOUT_URL return } else { - await client.auth.signout() + const resp = await postSignout({}) + + if (resp.status !== 204) { + throw new Error(resp.data.message) + } + this.props.router.push(`/signin`) } } diff --git a/ui/src/onboarding/actions/index.ts b/ui/src/onboarding/actions/index.ts index b50773ff8d..cb834493dd 100644 --- a/ui/src/onboarding/actions/index.ts +++ b/ui/src/onboarding/actions/index.ts @@ -11,6 +11,7 @@ import {notify} from 'src/shared/actions/notifications' // APIs import {client} from 'src/utils/api' +import * as api from 'src/client' // Types import {ISetupParams} from '@influxdata/influx' @@ -82,7 +83,11 @@ export const setupAdmin = (params: ISetupParams) => async ( const {username, password} = params - await client.auth.signin(username, password) + const resp = await api.postSignin({auth: {username, password}}) + + if (resp.status !== 204) { + throw new Error(resp.data.message) + } await client.templates.create({...defaultTemplates.systemTemplate(), orgID}) await client.templates.create({ diff --git a/ui/src/onboarding/components/SigninForm.tsx b/ui/src/onboarding/components/SigninForm.tsx index 6f98aba278..3b312b9e31 100644 --- a/ui/src/onboarding/components/SigninForm.tsx +++ b/ui/src/onboarding/components/SigninForm.tsx @@ -8,7 +8,7 @@ import _, {get} from 'lodash' import {Form, Input, Button, Grid} from '@influxdata/clockface' // APIs -import {client} from 'src/utils/api' +import {postSignin} from 'src/client' // Actions import {notify as notifyAction} from 'src/shared/actions/notifications' @@ -107,7 +107,12 @@ class SigninForm extends PureComponent { const {username, password} = this.state try { - await client.auth.signin(username, password) + const resp = await postSignin({auth: {username, password}}) + + if (resp.status !== 204) { + throw new Error(resp.data.message) + } + this.handleRedirect() } catch (error) { const message = get(error, 'response.data.msg', '') diff --git a/ui/yarn.lock b/ui/yarn.lock index f8c3cd6384..c9632acba6 100644 --- a/ui/yarn.lock +++ b/ui/yarn.lock @@ -1036,10 +1036,10 @@ lodash "^4.17.10" to-fast-properties "^2.0.0" -"@chnn/oats@0.2.1": - version "0.2.1" - resolved "https://registry.yarnpkg.com/@chnn/oats/-/oats-0.2.1.tgz#ebbea5807687ce6c555158b87625a368e1fe4cbb" - integrity sha512-1WjsZ4XodmH+5pi1Fi5+bUkh4OHUYqpIW6X9Js594Zj9hy5CHAwo9RlAKqTKfbBFXA842MFkEAhOp7hQvc9lnA== +"@chnn/oats@0.3.0": + version "0.3.0" + resolved "https://registry.yarnpkg.com/@chnn/oats/-/oats-0.3.0.tgz#86c398f0ce5a248f45db6bdf490ac8141495f7e1" + integrity sha512-6zAsbx+TyQvLaukkpG102aB9Ki4yseRrb20xNDDVM/DXyj50zA1ivIf5cwo+mVeAUvXaxLnoR9PR3J8BRdrtrA== dependencies: commander "^2.20.0" humps "^2.0.1"