Skip to content

Commit 267815b

Browse files
authored
Merge pull request #1362 from ravikumar1002/feat/github-created-at
Feat/GitHub created at
2 parents af81b7f + 1b745bf commit 267815b

File tree

3 files changed

+10
-2
lines changed

3 files changed

+10
-2
lines changed

controllers/auth.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,10 @@ const githubAuthCallback = (req, res, next) => {
4949
logger.error(err);
5050
return res.boom.unauthorized("User cannot be authenticated");
5151
}
52-
5352
userData = {
5453
github_id: user.username,
5554
github_display_name: user.displayName,
56-
// github_account_created_at: user.created_at,
55+
github_created_at: Number(new Date(user._json.created_at).getTime()),
5756
created_at: Date.now(),
5857
updated_at: Date.now(),
5958
};

test/fixtures/user/user.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ module.exports = () => {
1919
linkedin_id: "ankurnarkhede",
2020
github_id: githubUserInfo[0].username,
2121
github_display_name: githubUserInfo[0].displayName,
22+
github_created_at: Number(new Date(githubUserInfo[0]._json.created_at).getTime()),
2223
isMember: true,
2324
phone: "1234567890",
2425

test/unit/models/users.test.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,14 @@ describe("users", function () {
102102
expect(user).to.haveOwnProperty("updated_at");
103103
expect(userExists).to.equal(true);
104104
});
105+
106+
it("It should have github_created_at fields", async function () {
107+
const userData = userDataArray[0];
108+
await users.addOrUpdate(userData);
109+
const githubUsername = "ankur";
110+
const { user } = await users.fetchUser({ githubUsername });
111+
expect(user).to.haveOwnProperty("github_created_at");
112+
});
105113
});
106114

107115
describe("user image verification", function () {

0 commit comments

Comments
 (0)