add query in keycloak
All checks were successful
Spell Check / Spell Check with Typos (push) Successful in 5s
All checks were successful
Spell Check / Spell Check with Typos (push) Successful in 5s
This commit is contained in:
parent
d15aa488c1
commit
1d6224da73
2 changed files with 6 additions and 5 deletions
|
|
@ -1,4 +1,4 @@
|
||||||
import { Body, Controller, Delete, Get, Path, Post, Route, Security, Tags } from "tsoa";
|
import { Body, Controller, Delete, Get, Path, Post, Query, Route, Security, Tags } from "tsoa";
|
||||||
import { addUserRoles, getGroup, listRole, removeUserRoles } from "../services/keycloak";
|
import { addUserRoles, getGroup, listRole, removeUserRoles } from "../services/keycloak";
|
||||||
|
|
||||||
@Route("api/v1/keycloak")
|
@Route("api/v1/keycloak")
|
||||||
|
|
@ -46,8 +46,9 @@ export class KeycloakController extends Controller {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Get("group")
|
@Get("group")
|
||||||
async getGroup() {
|
async getGroup(@Query() query: string = "") {
|
||||||
const group = await getGroup();
|
const querySearch = query === "" ? "q" : `search=${query}`;
|
||||||
|
const group = await getGroup(querySearch);
|
||||||
if (!Array.isArray(group)) throw new Error("Failed. Cannot get group(s) data from the server.");
|
if (!Array.isArray(group)) throw new Error("Failed. Cannot get group(s) data from the server.");
|
||||||
|
|
||||||
return group;
|
return group;
|
||||||
|
|
|
||||||
|
|
@ -346,8 +346,8 @@ export async function removeUserRoles(userId: string, roles: { id: string; name:
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function getGroup() {
|
export async function getGroup(query: string) {
|
||||||
const res = await fetch(`${KC_URL}/admin/realms/${KC_REALM}/groups?q`, {
|
const res = await fetch(`${KC_URL}/admin/realms/${KC_REALM}/groups?${query}`, {
|
||||||
headers: {
|
headers: {
|
||||||
authorization: `Bearer ${await getToken()}`,
|
authorization: `Bearer ${await getToken()}`,
|
||||||
"content-type": `application/json`,
|
"content-type": `application/json`,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue