Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tweak(datatrak): RN-1492: Save last login date of meditrak devices #5941

Merged
merged 5 commits into from
Oct 6, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions packages/auth/src/Authenticator.js
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@ export class Authenticator {
}

async saveMeditrakDevice(user, meditrakDeviceDetails) {
console.log('saveMeditrakDevice', user.id, meditrakDeviceDetails);
tcaiger marked this conversation as resolved.
Show resolved Hide resolved
if (!meditrakDeviceDetails) return null;
const { installId, platform, appVersion } = meditrakDeviceDetails;
return this.models.meditrakDevice.updateOrCreate(
Expand All @@ -188,6 +189,7 @@ export class Authenticator {
user_id: user.id,
platform,
app_version: appVersion,
last_login: new Date(),
},
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,15 @@ import { testAuthenticateRefreshToken } from './testAuthenticateRefreshToken';
jest.mock('rand-token');
randomToken.generate.mockReturnValue(refreshToken);

beforeAll(() => {
jest.useFakeTimers('modern');
jest.setSystemTime(new Date(2020, 3, 1));
});

afterAll(() => {
jest.useRealTimers();
});

describe('Authenticator', () => {
describe('authenticatePassword', testAuthenticatePassword);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ export const testAuthenticatePassword = () => {
user_id: verifiedUser.id,
app_version: meditrakDeviceDetails.appVersion,
platform: meditrakDeviceDetails.platform,
last_login: new Date(),
},
);

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
'use strict';

var dbm;
var type;
var seed;

/**
* We receive the dbmigrate dependency from dbmigrate initially.
* This enables us to not have to rely on NODE_PATH.
*/
exports.setup = function (options, seedLink) {
dbm = options.dbmigrate;
type = dbm.dataType;
seed = seedLink;
};

exports.up = function (db) {
return db.runSql(`
ALTER TABLE meditrak_device
ADD COLUMN last_login TIMESTAMP;
`);
};

exports.down = function (db) {
return db.runSql(`
ALTER TABLE meditrak_device DROP COLUMN last_login;
`);
};

exports._meta = {
version: 1,
};
12 changes: 12 additions & 0 deletions packages/types/src/schemas/schemas.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions packages/types/src/types/models.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.