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";
|
||||
|
||||
@Route("api/v1/keycloak")
|
||||
|
|
@ -46,8 +46,9 @@ export class KeycloakController extends Controller {
|
|||
}
|
||||
|
||||
@Get("group")
|
||||
async getGroup() {
|
||||
const group = await getGroup();
|
||||
async getGroup(@Query() query: string = "") {
|
||||
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.");
|
||||
|
||||
return group;
|
||||
|
|
|
|||
|
|
@ -346,8 +346,8 @@ export async function removeUserRoles(userId: string, roles: { id: string; name:
|
|||
return true;
|
||||
}
|
||||
|
||||
export async function getGroup() {
|
||||
const res = await fetch(`${KC_URL}/admin/realms/${KC_REALM}/groups?q`, {
|
||||
export async function getGroup(query: string) {
|
||||
const res = await fetch(`${KC_URL}/admin/realms/${KC_REALM}/groups?${query}`, {
|
||||
headers: {
|
||||
authorization: `Bearer ${await getToken()}`,
|
||||
"content-type": `application/json`,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue