Skip to content

Commit 8d8775a

Browse files
authored
Merge pull request #16 from Lambda-School-Labs/feature/accesstoken-github-api
added accesstoken to user table
2 parents be4b723 + d00607e commit 8d8775a

File tree

3 files changed

+9
-4
lines changed

3 files changed

+9
-4
lines changed

src/api/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ module.exports.createExpressApp = (store) => {
3333
},
3434
async (accessToken, refreshToken, profile, done) => {
3535
try {
36-
let user = await findOrCreateUser(profile, store);
36+
let user = await findOrCreateUser(profile, store, accessToken);
3737
let repositories = await getRepositories(
3838
accessToken,
3939
user.dataValues.login,

src/datasources/actions.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const cleanProfile = (profile) => ({
1+
const cleanProfile = (profile, accessToken) => ({
22
avatarUrl: `${profile._json.avatar_url}`,
33
bio: `${profile._json.bio}`,
44
githubUrl: `${profile._json.html_url}`,
@@ -8,6 +8,7 @@ const cleanProfile = (profile) => ({
88
login: `${profile._json.login}`,
99
name: `${profile._json.name}`,
1010
websiteUrl: `${profile._json.blog}`,
11+
accessToken: `${accessToken}`
1112
});
1213

1314
const cleanRepository = (id, repository) => ({
@@ -24,8 +25,8 @@ const cleanRepository = (id, repository) => ({
2425
isStarred: repository.isStarred
2526
});
2627

27-
const findOrCreateUser = async (rawProfile, store) => {
28-
let profile = cleanProfile(rawProfile);
28+
const findOrCreateUser = async (rawProfile, store, accessToken) => {
29+
let profile = cleanProfile(rawProfile, accessToken);
2930
try {
3031
let user = await store.user.findByPk(profile.id);
3132
if (!user) {

src/datasources/models/user.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,10 @@ const user = (sequelize, DataTypes) => {
5151
type: DataTypes.STRING,
5252
allowNull: false,
5353
},
54+
accessToken: {
55+
type: DataTypes.STRING,
56+
allowNull: false,
57+
}
5458
},
5559
{
5660
timestamps: false,

0 commit comments

Comments
 (0)