-
Couldn't load subscription status.
- Fork 17
feat(Clusters): authorize with meta #2988
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -146,3 +146,11 @@ type TabletPageQuery = QueryParamsTypeFromQueryObject<typeof tabletPageQueryPara | |||||||||||||||||||||
| export function getTabletPagePath(tabletId: string | number, query: TabletPageQuery = {}) { | ||||||||||||||||||||||
| return createHref(routes.tablet, {id: tabletId}, {...query}); | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| export function checkIsClustersPage(pathname: string) { | ||||||||||||||||||||||
| return pathname.endsWith(routes.clusters); | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| export function checkIsTenantPage(pathname: string) { | ||||||||||||||||||||||
| return pathname.endsWith(routes.tenant); | ||||||||||||||||||||||
|
Comment on lines
+151
to
+155
|
||||||||||||||||||||||
| return pathname.endsWith(routes.clusters); | |
| } | |
| export function checkIsTenantPage(pathname: string) { | |
| return pathname.endsWith(routes.tenant); | |
| return pathname === routes.clusters; | |
| } | |
| export function checkIsTenantPage(pathname: string) { | |
| return pathname === routes.tenant; |
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -8,6 +8,7 @@ import type { | |||||||||
| MetaClusters, | ||||||||||
| MetaTenants, | ||||||||||
| } from '../../types/api/meta'; | ||||||||||
| import type {TUserToken} from '../../types/api/whoami'; | ||||||||||
| import {parseMetaTenants} from '../parsers/parseMetaTenants'; | ||||||||||
|
|
||||||||||
| import type {AxiosOptions, BaseAPIParams} from './base'; | ||||||||||
|
|
@@ -28,6 +29,14 @@ export class MetaAPI extends BaseYdbAPI { | |||||||||
| return `${META_BACKEND ?? ''}${path}`; | ||||||||||
| } | ||||||||||
|
|
||||||||||
| metaAuthenticate(params: {user: string; password: string}) { | ||||||||||
| return this.post(this.getPath('/meta/login'), params, {}); | ||||||||||
|
Comment on lines
+32
to
+33
|
||||||||||
| metaAuthenticate(params: {user: string; password: string}) { | |
| return this.post(this.getPath('/meta/login'), params, {}); | |
| metaAuthenticate(params: {user: string; password: string}): Promise<TUserToken> { | |
| return this.post<TUserToken>(this.getPath('/meta/login'), params, {}); |
| Original file line number | Diff line number | Diff line change | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -52,9 +52,17 @@ export const {selectIsUserAllowedToMakeChanges, selectIsViewerUser, selectUser} | |||||||||||
| export const authenticationApi = api.injectEndpoints({ | ||||||||||||
| endpoints: (build) => ({ | ||||||||||||
| whoami: build.query({ | ||||||||||||
| queryFn: async ({database}: {database?: string}, {dispatch}) => { | ||||||||||||
| queryFn: async ( | ||||||||||||
| {database, useMeta}: {database?: string; useMeta?: boolean}, | ||||||||||||
| {dispatch}, | ||||||||||||
| ) => { | ||||||||||||
| try { | ||||||||||||
| const data = await window.api.viewer.whoami({database}); | ||||||||||||
| let data: TUserToken; | ||||||||||||
| if (useMeta && window.api.meta) { | ||||||||||||
| data = await window.api.meta.metaWhoami(); | ||||||||||||
| } else { | ||||||||||||
| data = await window.api.viewer.whoami({database}); | ||||||||||||
| } | ||||||||||||
| dispatch(setUser(data)); | ||||||||||||
| return {data}; | ||||||||||||
| } catch (error) { | ||||||||||||
|
|
@@ -68,11 +76,17 @@ export const authenticationApi = api.injectEndpoints({ | |||||||||||
| }), | ||||||||||||
| authenticate: build.mutation({ | ||||||||||||
| queryFn: async ( | ||||||||||||
| params: {user: string; password: string; database?: string}, | ||||||||||||
| params: {user: string; password: string; database?: string; useMeta?: boolean}, | ||||||||||||
| {dispatch}, | ||||||||||||
| ) => { | ||||||||||||
| try { | ||||||||||||
| const data = await window.api.auth.authenticate(params); | ||||||||||||
| const {useMeta, ...rest} = params; | ||||||||||||
| let data; | ||||||||||||
| if (useMeta) { | ||||||||||||
| data = await window.api.meta?.metaAuthenticate(rest); | ||||||||||||
|
||||||||||||
| data = await window.api.meta?.metaAuthenticate(rest); | |
| if (!window.api.meta) { | |
| throw new Error('Meta API is not available for authentication'); | |
| } | |
| data = await window.api.meta.metaAuthenticate(rest); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] The
undefinedparameter was removed but the function call was changed fromuseAuthenticateMutation(undefined)touseAuthenticateMutation(). While functionally equivalent, the explicit change in the diff suggests this may have been intentional. Verify this change is necessary and not just a formatting modification.