Skip to content

Commit c27ffc7

Browse files
committed
Fix for broken impersonation - race condition
1 parent 2e8a3e3 commit c27ffc7

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

client/src/tabs/Users.jsx

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import I18n from "../locale/I18n";
33
import "../components/Entities.scss";
44
import {Chip, ChipType, Tooltip} from "@surfnet/sds";
55
import {Entities} from "../components/Entities";
6-
import {searchUsers} from "../api";
6+
import {other, searchUsers} from "../api";
77
import UserIcon from "@surfnet/sds/icons/functional-icons/id-2.svg";
88
import "./Users.scss";
99
import {isEmpty, stopEvent} from "../utils/Utils";
@@ -120,9 +120,12 @@ export const Users = () => {
120120
const showImpersonation = currentUser && currentUser.superUser;
121121

122122
const impersonate = user => {
123-
startImpersonation(user);
124-
setFlash(I18n.t("impersonate.flash.startedImpersonation", {name: user.name}));
125-
navigate("/", {replace: true});
123+
//First, fetch the entire other user otherwise we get undefined errors
124+
other(user.id).then(otherUser => {
125+
startImpersonation(otherUser);
126+
setFlash(I18n.t("impersonate.flash.startedImpersonation", {name: otherUser.name}));
127+
navigate("/", {replace: true});
128+
})
126129
}
127130

128131
if (showImpersonation) {

0 commit comments

Comments
 (0)