Skip to content

Commit dbb8824

Browse files
fix: improves how code access user-agent in the headers (RocketChat#37493)
1 parent 4432e51 commit dbb8824

2 files changed

Lines changed: 8 additions & 4 deletions

File tree

.changeset/healthy-rabbits-sip.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@rocket.chat/meteor": patch
3+
---
4+
5+
Fixes an issue where `user-agent` is not properly extracted from the DDP connection headers

apps/meteor/ee/server/lib/deviceManagement/session.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import { Users } from '@rocket.chat/models';
33
import { Accounts } from 'meteor/accounts-base';
44
import { Meteor } from 'meteor/meteor';
55
import moment from 'moment';
6-
import type { Headers } from 'node-fetch';
76
import { UAParser } from 'ua-parser-js';
87

98
import * as Mailer from '../../../../app/mailer/server/api';
@@ -67,9 +66,9 @@ export const listenSessionLogin = () => {
6766
username,
6867
emails: [{ address: email }],
6968
} = user;
70-
// TODO: Find why the httpheaders is being casted to IncomingHttpHeaders instead of Headers
71-
const userAgentString = connection?.httpHeaders && (connection.httpHeaders as unknown as Headers).get('user-agent');
72-
const { browser, os, device, cpu, app } = await uaParser(userAgentString || '');
69+
70+
const userAgentString = connection?.httpHeaders?.['user-agent'] ?? '';
71+
const { browser, os, device, cpu, app } = await uaParser(userAgentString);
7372

7473
const mailData = {
7574
name,

0 commit comments

Comments
 (0)