Skip to content
Merged
Show file tree
Hide file tree
Changes from 7 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
3 changes: 1 addition & 2 deletions controllers/auth.js
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
};
Expand Down
44 changes: 44 additions & 0 deletions test/fixtures/auth/githubUserInfo.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,5 +101,49 @@ module.exports = () => {
created_at: "2020-09-06T16:21:38Z",
updated_at: "2023-07-26T09:29:37Z",
},
{
id: "86847625",
nodeId: "MDQ6VXNlcjg2ODQ3NjI1",
displayName: "Ravi kumar",
username: "ravikumar1002",
profileUrl: "https://github.com/ravikumar1002",
photos: [{ value: "https://avatars.githubusercontent.com/u/86847625?v=4" }],
provider: "github",
_raw: '{"login":"ravikumar1002","id":86847625,"node_id":"MDQ6VXNlcjg2ODQ3NjI1","avatar_url":"https://avatars.githubusercontent.com/u/86847625?v=4","gravatar_id":"","url":"https://api.github.com/users/ravikumar1002","html_url":"https://github.com/ravikumar1002","followers_url":"https://api.github.com/users/ravikumar1002/followers","following_url":"https://api.github.com/users/ravikumar1002/following{/other_user}","gists_url":"https://api.github.com/users/ravikumar1002/gists{/gist_id}","starred_url":"https://api.github.com/users/ravikumar1002/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ravikumar1002/subscriptions","organizations_url":"https://api.github.com/users/ravikumar1002/orgs","repos_url":"https://api.github.com/users/ravikumar1002/repos","events_url":"https://api.github.com/users/ravikumar1002/events{/privacy}","received_events_url":"https://api.github.com/users/ravikumar1002/received_events","type":"User","site_admin":false,"name":"Ravi kumar","company":null,"blog":"https://ravikumar.dev/","location":"Delhi, India","email":null,"hireable":null,"bio":"Frontend developer","twitter_username":"kumarravi1002","public_repos":47,"public_gists":0,"followers":9,"following":13,"created_at":"2021-07-02T16:40:44Z","updated_at":"2023-07-27T00:12:32Z"}',
_json: {
login: "ravikumar1002",
id: 86847625,
node_id: "MDQ6VXNlcjg2ODQ3NjI1",
avatar_url: "https://avatars.githubusercontent.com/u/86847625?v=4",
gravatar_id: "",
url: "https://api.github.com/users/ravikumar1002",
html_url: "https://github.com/ravikumar1002",
followers_url: "https://api.github.com/users/ravikumar1002/followers",
following_url: "https://api.github.com/users/ravikumar1002/following{/other_user}",
gists_url: "https://api.github.com/users/ravikumar1002/gists{/gist_id}",
starred_url: "https://api.github.com/users/ravikumar1002/starred{/owner}{/repo}",
subscriptions_url: "https://api.github.com/users/ravikumar1002/subscriptions",
organizations_url: "https://api.github.com/users/ravikumar1002/orgs",
repos_url: "https://api.github.com/users/ravikumar1002/repos",
events_url: "https://api.github.com/users/ravikumar1002/events{/privacy}",
received_events_url: "https://api.github.com/users/ravikumar1002/received_events",
type: "User",
site_admin: false,
name: "Ravi kumar",
company: null,
blog: "https://ravikumar.dev/",
location: "Delhi, India",
email: null,
hireable: null,
bio: "Frontend developer",
twitter_username: "kumarravi1002",
public_repos: 47,
public_gists: 0,
followers: 9,
following: 13,
created_at: "2021-07-02T16:40:44Z",
updated_at: "2023-07-27T00:12:32Z",
},
},
];
};
15 changes: 15 additions & 0 deletions test/fixtures/user/user.js
Original file line number Diff line number Diff line change
Expand Up @@ -343,5 +343,20 @@ module.exports = () => {
updated_at: Date.now(),
created_at: Date.now(),
},
{
username: "ravikumar1002",
first_name: "ravi",
last_name: "kumar",
github_id: githubUserInfo[2].username,
github_display_name: githubUserInfo[2].displayName,
github_created_at: Number(new Date(githubUserInfo[2]._json.created_at).getTime()),
roles: {
member: false,
in_discord: true,
},
incompleteUserDetails: false,
updated_at: Date.now(),
created_at: Date.now(),
},
];
};
8 changes: 8 additions & 0 deletions test/unit/models/users.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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[15];
await users.addOrUpdate(userData);
const githubUsername = "ravikumar1002";
const { user } = await users.fetchUser({ githubUsername });
expect(user).to.haveOwnProperty("github_created_at");
});
});

describe("user image verification", function () {
Expand Down