Skip to content

Commit

Permalink
tweak(datatrak): RN-1492: Save last login date of meditrak devices (#…
Browse files Browse the repository at this point in the history
…5941)

* save last login date

* generate types

* Update setupNewDatabase.sh

* update auth tests

* Update packages/auth/src/Authenticator.js

Co-authored-by: Jasper Lai <33956381+jaskfla@users.noreply.github.com>

---------

Co-authored-by: Jasper Lai <33956381+jaskfla@users.noreply.github.com>
  • Loading branch information
tcaiger and jaskfla authored Oct 6, 2024
1 parent 60ce162 commit 84846fa
Show file tree
Hide file tree
Showing 6 changed files with 58 additions and 0 deletions.
1 change: 1 addition & 0 deletions packages/auth/src/Authenticator.js
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,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.

0 comments on commit 84846fa

Please sign in to comment.