Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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: 1 addition & 1 deletion src/api/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ module.exports.createExpressApp = (store) => {
},
async (accessToken, refreshToken, profile, done) => {
try {
let user = await findOrCreateUser(profile, store);
let user = await findOrCreateUser(profile, store, accessToken);
let repositories = await getRepositories(
accessToken,
user.dataValues.login,
Expand Down
7 changes: 4 additions & 3 deletions src/datasources/actions.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const cleanProfile = (profile) => ({
const cleanProfile = (profile, accessToken) => ({
avatarUrl: `${profile._json.avatar_url}`,
bio: `${profile._json.bio}`,
githubUrl: `${profile._json.html_url}`,
Expand All @@ -8,6 +8,7 @@ const cleanProfile = (profile) => ({
login: `${profile._json.login}`,
name: `${profile._json.name}`,
websiteUrl: `${profile._json.blog}`,
accessToken: `${accessToken}`
});

const cleanRepository = (id, repository) => ({
Expand All @@ -24,8 +25,8 @@ const cleanRepository = (id, repository) => ({
isStarred: repository.isStarred
});

const findOrCreateUser = async (rawProfile, store) => {
let profile = cleanProfile(rawProfile);
const findOrCreateUser = async (rawProfile, store, accessToken) => {
let profile = cleanProfile(rawProfile, accessToken);
try {
let user = await store.user.findByPk(profile.id);
if (!user) {
Expand Down
4 changes: 4 additions & 0 deletions src/datasources/models/user.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ const user = (sequelize, DataTypes) => {
type: DataTypes.STRING,
allowNull: false,
},
accessToken: {
type: DataTypes.STRING,
allowNull: false,
}
},
{
timestamps: false,
Expand Down