Skip to content

Commit

Permalink
Don't expect name in auth response, we don't use it anyways
Browse files Browse the repository at this point in the history
  • Loading branch information
Tripperful committed Feb 12, 2024
1 parent 769a77a commit 53564ed
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 13 deletions.
2 changes: 1 addition & 1 deletion packages/client/src/components/MatchMenu/MatchPlayers.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ const MatchPlayerItem: FC<{
return (
<div className={c.playerItem}>
<span className={c.teamColor}>
{player.steamProfile?.name ?? player.name}
{player.steamProfile?.name ?? player.steamId}
</span>
<span className={c.playerTeamButtons}>
{teams
Expand Down
3 changes: 1 addition & 2 deletions packages/client/src/srcds-mock/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ const App: FC = () => {
token,
userId,
steamId,
name,
};

setPlayers((cur) => [...cur, newPlayer]);
Expand Down Expand Up @@ -109,7 +108,7 @@ const App: FC = () => {
rel="noreferrer"
href={`${location.protocol}//${location.host}?guid=test&token=${p.token}`}
>
{p.name}
{p.steamId}
</a>
&nbsp;
<button onClick={() => onDeletePlayer(p.token)}>X</button>
Expand Down
1 change: 0 additions & 1 deletion packages/common/src/types/players.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { SteamPlayerData } from './steam';

export interface OnlinePlayerInfo {
steamId: string;
name: string;
userId: number;
steamProfile?: SteamPlayerData;
}
Expand Down
4 changes: 2 additions & 2 deletions packages/server/src/api/log.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@ logApi.post('/:severity', async (req, res) => {
try {
const { sessionData } = res.locals;

const { token, name, steamId } = sessionData ?? {};
const { token, steamId } = sessionData ?? {};

const severity = req.params.severity as Severity;
const log = req.body;

const logFunc = logFuncMap[severity];

logFunc?.(
`@@@ Client ${severity} from player ${name} (token: ${token}, steamid: ${steamId}):`,
`@@@ Client ${severity} from player (token: ${token}, steamid: ${steamId}):`,
'\n' + log,
);

Expand Down
10 changes: 3 additions & 7 deletions packages/server/src/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,12 @@ import { RequestHandler } from 'express';
import { db } from './db';
import { getSrcdsApi } from './srcdsApi';
import { SrcdsApi } from './srcdsApi/SrcdsApi';
import { dbgInfo, dbgWarn } from './util';
import { dbgWarn } from './util';

export interface MotdSessionData {
protocol: SrcdsProtocol;
remoteId: string;
token: string;
name: string;
userId: number;
steamId: string;
permissions: Permission[];
Expand All @@ -26,7 +25,7 @@ const getUserCredentials = async (
if (!authCache[token]) {
const auth = await srcdsApi.auth(token);

if (!(auth.name && auth.userId && auth.steamId)) {
if (!(auth.userId && auth.steamId)) {
delete authCache[token];

throw 'Unauthorized';
Expand Down Expand Up @@ -78,14 +77,13 @@ export const authMiddleware: RequestHandler = async (req, res, next) => {
const srcdsApi = getSrcdsApi({ protocol, remoteId });
res.locals.srcdsApi = srcdsApi;

const { steamId, name, userId } = await getUserCredentials(token, srcdsApi);
const { steamId, userId } = await getUserCredentials(token, srcdsApi);
const permissions = await db.permissions.get(steamId);

res.locals.sessionData = {
protocol,
remoteId,
token,
name,
userId,
steamId,
permissions,
Expand All @@ -95,7 +93,6 @@ export const authMiddleware: RequestHandler = async (req, res, next) => {
res.cookie('protocol', protocol);
res.cookie('remoteId', remoteId);
res.cookie('token', token, { httpOnly: true });
res.cookie('name', name);
res.cookie('userId', userId);
res.cookie('steamId', steamId);
res.cookie('permissions', JSON.stringify(permissions));
Expand All @@ -106,7 +103,6 @@ export const authMiddleware: RequestHandler = async (req, res, next) => {
res.clearCookie('token');
res.clearCookie('protocol');
res.clearCookie('remoteId');
res.clearCookie('name');
res.clearCookie('userId');
res.clearCookie('steamId');
res.clearCookie('permissions');
Expand Down

0 comments on commit 53564ed

Please sign in to comment.