try {
$this->authorize('seeResults', $round);
} catch (AuthorizationException) {
- $round->hideResults();
+ $round->hideResults($request->user());
}
}
$json = $tournament->toArray();
try {
$this->authorize('seeResults', $round);
} catch (AuthorizationException) {
- $round->hideResults();
+ $round->hideResults($request->user());
}
}
return $rounds->toArray();
}
- public function hideResults() {
+ public function hideResults(User $user = null) {
foreach ($this->results as $result) {
- $result->makeHidden(['forfeit', 'placement', 'score', 'time']);
+ if (!$user || $result->user_id != $user->id) {
+ $result->makeHidden(['forfeit', 'placement', 'score', 'time']);
+ }
}
}
import Box from '../users/Box';
import { getTime } from '../../helpers/Result';
-import { maySeeResults } from '../../helpers/permissions';
+import { maySeeResult } from '../../helpers/permissions';
import { findResult } from '../../helpers/User';
import { useUser } from '../../hooks/user';
[round, user],
);
const maySee = React.useMemo(
- () => maySeeResults(authUser, tournament, round),
- [authUser, round, tournament],
+ () => maySeeResult(authUser, tournament, round, result),
+ [authUser, result, round, tournament],
);
return <Modal className="result-dialog" onHide={onHide} show={show}>
import Icon from '../common/Icon';
import Box from '../users/Box';
import { getIcon, getTime } from '../../helpers/Result';
-import { maySeeResults } from '../../helpers/permissions';
+import { maySeeResult } from '../../helpers/permissions';
import { findResult } from '../../helpers/User';
import { useUser } from '../../hooks/user';
[round, user],
);
const maySee = React.useMemo(
- () => maySeeResults(authUser, tournament, round),
- [authUser, round, tournament],
+ () => maySeeResult(authUser, tournament, round, result),
+ [authUser, result, round, tournament],
);
return <div className="result">
return false;
};
+export const maySeeResult = (user, tournament, round, result) => {
+ if (user && result && user.id === result.user_id) {
+ return true;
+ }
+ return maySeeResults(user, tournament, round);
+};
+
// Twitch
export const mayManageTwitchBot = user => isAnyChannelAdmin(user);