Skip to content

Commit ab7d810

Browse files
fix: login device email undefined values (RocketChat#36880)
1 parent 0786c86 commit ab7d810

2 files changed

Lines changed: 9 additions & 1 deletion

File tree

.changeset/thin-parents-beam.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 issue with Login Detection emails showing undefined values instead of the user agent info

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ 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';
67
import { UAParser } from 'ua-parser-js';
78

89
import * as Mailer from '../../../../app/mailer/server/api';
@@ -66,7 +67,9 @@ export const listenSessionLogin = () => {
6667
username,
6768
emails: [{ address: email }],
6869
} = user;
69-
const { browser, os, device, cpu, app } = await uaParser(connection.httpHeaders['user-agent']);
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 || '');
7073

7174
const mailData = {
7275
name,

0 commit comments

Comments
 (0)