[BREAK] Remove patch info from endpoint /api/info for non-logged in users (#16050)
Co-authored-by: Diego Sampaio <chinello@gmail.com>pull/22528/head
parent
713f801358
commit
6a6313aa51
@ -0,0 +1,22 @@ |
||||
|
||||
import { Info } from '../../../utils/server'; |
||||
import { hasRoleAsync } from '../../../authorization/server/functions/hasRole'; |
||||
|
||||
type ServerInfo = { |
||||
info: Info; |
||||
} | { |
||||
version: string | undefined; |
||||
}; |
||||
|
||||
const removePatchInfo = (version: string): string => version.replace(/(\d+\.\d+).*/, '$1'); |
||||
|
||||
export async function getServerInfo(userId?: string): Promise<ServerInfo> { |
||||
if (await hasRoleAsync(userId, 'admin')) { |
||||
return { |
||||
info: Info, |
||||
}; |
||||
} |
||||
return { |
||||
version: removePatchInfo(Info.version), |
||||
}; |
||||
} |
||||
Loading…
Reference in new issue