Skip to content

Commit 14f1a15

Browse files
authored
feat: update polling /me endpoint (to be deprecated) to /identity endpoint (#4896)
1 parent 9b90edb commit 14f1a15

File tree

4 files changed

+12
-17
lines changed

4 files changed

+12
-17
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252
"cy": "CYPRESS_dexUrl=https://$INGRESS_HOST:$PORT_HTTPS CYPRESS_baseUrl=http://localhost:9999 cypress open",
5353
"cy:dev": "source ../monitor-ci/.env && CYPRESS_dexUrl=CLOUD CYPRESS_baseUrl=https://$INGRESS_HOST:$PORT_HTTPS cypress open --config testFiles='{cloud,shared}/**/*.*'",
5454
"cy:dev-oss": "source ../monitor-ci/.env && CYPRESS_dexUrl=OSS CYPRESS_baseUrl=https://$INGRESS_HOST:$PORT_HTTPS cypress open --config testFiles='{oss,shared}/**/*.*'",
55-
"generate": "export SHA=ec907d13bbe519a5d370088dd76473db804c2483 && export REMOTE=https://raw.githubusercontent.com/influxdata/openapi/${SHA}/ && yarn generate-meta",
55+
"generate": "export SHA=3ef04defe045c8333f458f0cc2959057183d217f && export REMOTE=https://raw.githubusercontent.com/influxdata/openapi/${SHA}/ && yarn generate-meta",
5656
"generate-local": "export REMOTE=../openapi/ && yarn generate-meta",
5757
"generate-meta": "if [ -z \"${CLOUD_URL}\" ]; then yarn generate-meta-oss; else yarn generate-meta-cloud; fi",
5858
"generate-meta-oss": "yarn oss-api && yarn notebooks && yarn unity && yarn annotations-oss && yarn pinned && yarn mapsd-oss && yarn uiproxyd-oss && yarn cloudPriv && yarn fluxdocs && yarn subscriptions-oss",

src/Signin.tsx

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,9 @@ import {
3131

3232
// Types
3333
import {RemoteDataState} from 'src/types'
34-
import {getMe} from 'src/client'
34+
35+
// APIs
36+
import {fetchIdentity} from './identity/apis/auth'
3537

3638
interface State {
3739
loading: RemoteDataState
@@ -95,12 +97,7 @@ export class Signin extends PureComponent<Props, State> {
9597

9698
private checkForLogin = async () => {
9799
try {
98-
const resp = await getMe({})
99-
100-
if (resp.status !== 200) {
101-
throw new Error(resp.data.message)
102-
}
103-
100+
await fetchIdentity()
104101
this.setState({auth: true})
105102
const redirectIsSet = !!getFromLocalStorage('redirectTo')
106103
if (redirectIsSet) {

src/identity/apis/auth.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,6 @@ export const fetchIdentity = async () => {
8989
return fetchLegacyIdentity()
9090
}
9191
// if we make it to this line we are in cloud and ui unification flag is on
92-
9392
if (isFlagEnabled('quartzIdentity')) {
9493
return fetchQuartzIdentity()
9594
}
@@ -137,6 +136,10 @@ export const fetchQuartzMe = async (): Promise<MeQuartz> => {
137136
const fetchLegacyIdentity = async (): Promise<UserResponseIdpe> => {
138137
const response = await getMeIdpe({})
139138

139+
if (response.status === 401) {
140+
throw new UnauthorizedError(response.data.message)
141+
}
142+
140143
if (response.status === 500) {
141144
const error: IdpeError = response.data
142145
throw new ServerError(error.message)

src/onboarding/containers/LoginPage.tsx

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ import {useHistory} from 'react-router-dom'
1111
import Notifications from 'src/shared/components/notifications/Notifications'
1212
import {CloudLogoWithCubo} from 'src/onboarding/components/CloudLogoWithCubo'
1313

14-
// Types
15-
import {getMe} from 'src/client'
14+
// APIs
15+
import {fetchIdentity} from 'src/identity/apis/auth'
1616

1717
// Components
1818
import ErrorBoundary from 'src/shared/components/ErrorBoundary'
@@ -25,12 +25,7 @@ export const LoginPage: FC = () => {
2525

2626
const getSessionValidity = useCallback(async () => {
2727
try {
28-
const resp = await getMe({})
29-
30-
if (resp.status !== 200) {
31-
throw new Error(resp.data.message)
32-
}
33-
28+
await fetchIdentity()
3429
setHasValidSession(true)
3530
} catch {
3631
setHasValidSession(false)

0 commit comments

Comments
 (0)