Skip to content

Commit

Permalink
Merge pull request #20037 from burczu/19007_secure-logins_date-utils
Browse files Browse the repository at this point in the history
feat: use `accountID` in `DateUtils`
  • Loading branch information
Beamanator authored Jun 5, 2023
2 parents 9e7425a + ca22874 commit 758ef37
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
3 changes: 3 additions & 0 deletions src/ONYXKEYS.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ export default {
// Contains all the personalDetails the user has access to
PERSONAL_DETAILS: 'personalDetails',

// Contains all the personalDetails the user has access to [new version]
PERSONAL_DETAILS_LIST: 'personalDetailsList',

// Contains all the private personal details of the user
PRIVATE_PERSONAL_DETAILS: 'private_personalDetails',

Expand Down
8 changes: 4 additions & 4 deletions src/libs/DateUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import CONST from '../CONST';
import * as Localize from './Localize';
import * as CurrentDate from './actions/CurrentDate';

let currentUserEmail;
let currentAccountID;
Onyx.connect({
key: ONYXKEYS.SESSION,
callback: (val) => {
Expand All @@ -20,15 +20,15 @@ Onyx.connect({
return;
}

currentUserEmail = val.email;
currentAccountID = val.accountID;
},
});

let timezone = CONST.DEFAULT_TIME_ZONE;
Onyx.connect({
key: ONYXKEYS.PERSONAL_DETAILS,
key: ONYXKEYS.PERSONAL_DETAILS_LIST,
callback: (val) => {
timezone = lodashGet(val, [currentUserEmail, 'timezone'], CONST.DEFAULT_TIME_ZONE);
timezone = lodashGet(val, [currentAccountID, 'timezone'], CONST.DEFAULT_TIME_ZONE);
},
});

Expand Down
4 changes: 2 additions & 2 deletions tests/unit/DateUtilsTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ describe('DateUtils', () => {
Onyx.init({
keys: ONYXKEYS,
initialKeyStates: {
[ONYXKEYS.SESSION]: {email: '[email protected]'},
[ONYXKEYS.PERSONAL_DETAILS]: {'[email protected]': {timezone: {selected: 'Etc/UTC'}}},
[ONYXKEYS.SESSION]: {accountID: 999},
[ONYXKEYS.PERSONAL_DETAILS_LIST]: {999: {timezone: {selected: 'Etc/UTC'}}},
},
});
return waitForPromisesToResolve();
Expand Down

0 comments on commit 758ef37

Please sign in to comment.