Skip to content

Commit a0b9607

Browse files
authored
Merge pull request #3 from oslabs-beta/noah/feature
Noah/feature
2 parents 947f53e + cf0f88a commit a0b9607

File tree

4 files changed

+24
-20
lines changed

4 files changed

+24
-20
lines changed

Dockerfile

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,8 @@ ENV IS_DOCKER=true
5656

5757
ENV VIDEOSDK='vidsdk'
5858

59-
# productino you dolt!, if we are using docker, its production!
6059
ENV PORT=5656
6160

62-
# no longer put the envs here cause we are not dumb.
61+
# no longer put the envs here
6362

6463
CMD [ "npm", "start" ]

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@
9090
"Zack Vandiver"
9191
],
9292
"scripts": {
93+
"prod-build": "vite build",
9394
"build": "vite build",
9495
"dev-frontend": "vite",
9596
"dev-server": "NODE_ENV=development nodemon server/server.ts",

server/models/Oauth-model.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,10 @@ interface UserDocument extends Document {
88

99
const userSchema = new mongoose.Schema<UserDocument>({
1010
username: { type: String },
11-
githubId: { type: String, unique: true },
12-
googleId: { type: String, unique: true }
11+
githubId: { type: String }, // removed unique constraint because you can have null values.
12+
googleId: { type: String } // unique:true
1313
});
1414

1515
const User = mongoose.model<UserDocument>('OauthUsers', userSchema);
1616

17-
1817
export default User;

server/routers/passport-setup.ts

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ passport.use(
3333
callbackURL: `${API_BASE_URL}/auth/github/callback`,
3434
proxy: true
3535
},
36-
function (accessToken, refreshToken, profile, done) {
36+
(accessToken, refreshToken, profile, done) => {
3737
user
3838
.findOne({
3939
githubId: profile.id
@@ -42,22 +42,27 @@ passport.use(
4242
if (currentUser) {
4343
console.log('user is: ', currentUser);
4444
return done(null, currentUser);
45+
}
46+
let initials;
47+
if (profile.displayName) {
48+
initials = profile.displayName.match(/\b\w/g).join('');
4549
} else {
46-
const initials = profile.displayName.match(/\b\w/g).join('');
47-
const nums = profile.id.slice(0, 5);
48-
user
49-
.create({
50-
username: initials + nums + '(Github)',
51-
githubId: profile.id
52-
})
53-
.then((data) => {
54-
console.log('user added successfully: ', data);
55-
return done(null, data);
56-
})
57-
.catch((data) =>
58-
console.log('issue with adding user to database', data)
59-
);
50+
initials = profile._json.login.match(/\b\w/g).join('');
6051
}
52+
53+
const nums = profile.id.slice(0, 5);
54+
user
55+
.create({
56+
username: initials + nums + '(Github)',
57+
githubId: profile.id
58+
})
59+
.then((data) => {
60+
console.log('user added successfully: ', data);
61+
return done(null, data);
62+
})
63+
.catch((data) =>
64+
console.log('issue with adding user to database', data)
65+
);
6166
});
6267
}
6368
)

0 commit comments

Comments
 (0)