Skip to content
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

Fix session invalidation #162

Merged
merged 1 commit into from
Nov 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,11 @@
* information: "Portions copyright [year] [name of copyright owner]".
*
* Copyright 2016 ForgeRock AS.
* Portions copyright 2023 Wren Security
*/

/**
* @module org/forgerock/openam/ui/admin/services/global/SessionsService
* @module org/forgerock/openam/ui/admin/services/realm/SessionsService
*/

import AbstractDelegate from "org/forgerock/commons/ui/common/main/AbstractDelegate";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,11 @@
* information: "Portions copyright [year] [name of copyright owner]".
*
* Copyright 2016 ForgeRock AS.
* Portions copyright 2023 Wren Security
*/

/**
* @module org/forgerock/openam/ui/admin/services/global/UsersService
* @module org/forgerock/openam/ui/admin/services/realm/UsersService
*/

import AbstractDelegate from "org/forgerock/commons/ui/common/main/AbstractDelegate";
Expand All @@ -24,9 +25,16 @@ import fetchUrl from "org/forgerock/openam/ui/common/services/fetchUrl";

const obj = new AbstractDelegate(`${Constants.host}/${Constants.context}/json`);

export function getByIdStartsWith (id) {
/**
* Fetch a list of users from the realm that start with the prefix.
*
* @param {string} id User ID prefix.
* @param {(string|boolean)} [realm=false] Realm.
* @returns {Promise<Array.<string>>} Promise with list of users.
*/
export function getByIdStartsWith (id, realm = false) {
return obj.serviceCall({
url: fetchUrl(`/users?_queryId=${id}*`, { realm: false }),
url: fetchUrl(`/users?_queryId=${id}*`, { realm }),
headers: { "Accept-API-Version": "protocol=1.0,resource=1.0" }
}).then((response) => response.result);
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,20 +22,20 @@ import Select from "react-select";
import {
getByUserIdAndRealm,
invalidateByHandles
} from "org/forgerock/openam/ui/admin/services/global/SessionsService";
import { getByIdStartsWith } from "org/forgerock/openam/ui/admin/services/global/UsersService";
} from "org/forgerock/openam/ui/admin/services/realm/SessionsService";
import { getByIdStartsWith } from "org/forgerock/openam/ui/admin/services/realm/UsersService";
import CallToAction from "components/CallToAction";
import PageDescription from "components/PageDescription";
import SessionsTable from "./SessionsTable";
import SimplePageHeader from "components/SimplePageHeader";
import withRouter from "org/forgerock/commons/ui/common/components/hoc/withRouter";
import withRouterPropType from "org/forgerock/commons/ui/common/components/hoc/withRouterPropType";

const fetchUsersByPartialId = _.debounce((userId, callback) => {
const fetchUsersByPartialId = _.debounce((userId, realm, callback) => {
if (_.isEmpty(userId)) {
callback(null, { options: [] });
} else {
getByIdStartsWith(userId).then((response) => {
getByIdStartsWith(userId, realm).then((response) => {
callback(null, {
options: _.map(response, (user) => ({ label: user, value: user }))
});
Expand Down Expand Up @@ -108,7 +108,7 @@ class SessionsView extends Component {
id: "findAUser"
} }
isLoading
loadOptions={ fetchUsersByPartialId }
loadOptions={ (userId, cb) => fetchUsersByPartialId(userId, this.props.router.params[0], cb) }
noResultsText={ t("console.sessions.search.noResults") }
onChange={ this.handleSelectAsyncOnChange }
placeholder={ t("console.sessions.search.placeholder") }
Expand Down
Loading