refactor(ui): migrate signin/signout to generated client

pull/14569/head
Christopher Henn 2019-08-09 15:54:26 -07:00
parent dc0d663364
commit 6d993a37c5
5 changed files with 25 additions and 10 deletions

View File

@ -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",

View File

@ -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<Props> {
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`)
}
}

View File

@ -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({

View File

@ -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<Props, State> {
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', '')

View File

@ -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"