sources: allow uuid or slug to be used for retrieving a source (#12780)
Signed-off-by: Jens Langhammer <jens@goauthentik.io>
This commit is contained in:
@ -4,7 +4,7 @@ import { DualSelectPair } from "@goauthentik/elements/ak-dual-select/types";
|
||||
import { OAuthSource, SourcesApi } from "@goauthentik/api";
|
||||
|
||||
const sourceToSelect = (source: OAuthSource) => [
|
||||
source.slug,
|
||||
source.pk,
|
||||
`${source.name} (${source.slug})`,
|
||||
source.name,
|
||||
source,
|
||||
@ -37,13 +37,15 @@ export function oauth2SourcesSelector(instanceMappings?: string[]) {
|
||||
const oauthSources = new SourcesApi(DEFAULT_CONFIG);
|
||||
const mappings = await Promise.allSettled(
|
||||
instanceMappings.map((instanceId) =>
|
||||
oauthSources.sourcesOauthRetrieve({ slug: instanceId }),
|
||||
oauthSources.sourcesOauthList({ pbmUuid: instanceId }),
|
||||
),
|
||||
);
|
||||
|
||||
return mappings
|
||||
.filter((s) => s.status === "fulfilled")
|
||||
.map((s) => s.value)
|
||||
.filter((s) => s.pagination.count > 0)
|
||||
.map((s) => s.results[0])
|
||||
.map(sourceToSelect);
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user