diff --git a/controllers/auth.js b/controllers/auth.js index 183f4a394..9c6554f68 100644 --- a/controllers/auth.js +++ b/controllers/auth.js @@ -49,11 +49,10 @@ const githubAuthCallback = (req, res, next) => { logger.error(err); return res.boom.unauthorized("User cannot be authenticated"); } - userData = { github_id: user.username, github_display_name: user.displayName, - // github_account_created_at: user.created_at, + github_created_at: Number(new Date(user._json.created_at).getTime()), created_at: Date.now(), updated_at: Date.now(), }; diff --git a/test/fixtures/user/user.js b/test/fixtures/user/user.js index caf2735c5..e9746fd39 100644 --- a/test/fixtures/user/user.js +++ b/test/fixtures/user/user.js @@ -19,6 +19,7 @@ module.exports = () => { linkedin_id: "ankurnarkhede", github_id: githubUserInfo[0].username, github_display_name: githubUserInfo[0].displayName, + github_created_at: Number(new Date(githubUserInfo[0]._json.created_at).getTime()), isMember: true, phone: "1234567890", email: "abc@gmail.com", diff --git a/test/unit/models/users.test.js b/test/unit/models/users.test.js index 42d7cad61..4fb868b21 100644 --- a/test/unit/models/users.test.js +++ b/test/unit/models/users.test.js @@ -102,6 +102,14 @@ describe("users", function () { expect(user).to.haveOwnProperty("updated_at"); expect(userExists).to.equal(true); }); + + it("It should have github_created_at fields", async function () { + const userData = userDataArray[0]; + await users.addOrUpdate(userData); + const githubUsername = "ankur"; + const { user } = await users.fetchUser({ githubUsername }); + expect(user).to.haveOwnProperty("github_created_at"); + }); }); describe("user image verification", function () {