fix(server): get remote ip (#3515)

This commit is contained in:
Jason Rasmussen 2023-08-02 07:50:42 -04:00 committed by GitHub
parent ee49f470b7
commit a336aeb007
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -61,14 +61,14 @@ export const AuthUser = createParamDecorator((data, ctx: ExecutionContext): Auth
});
export const GetLoginDetails = createParamDecorator((data, ctx: ExecutionContext): LoginDetails => {
const req = ctx.switchToHttp().getRequest();
const req = ctx.switchToHttp().getRequest<Request>();
const userAgent = UAParser(req.headers['user-agent']);
return {
clientIp: req.clientIp,
clientIp: req.ip,
isSecure: req.secure,
deviceType: userAgent.browser.name || userAgent.device.type || req.headers.devicemodel || '',
deviceOS: userAgent.os.name || req.headers.devicetype || '',
deviceType: userAgent.browser.name || userAgent.device.type || (req.headers.devicemodel as string) || '',
deviceOS: userAgent.os.name || (req.headers.devicetype as string) || '',
};
});