Skip to content

Commit b20492e

Browse files
committed
Co-authored-by: Philip Hua <[email protected]>
Co-authored-by: Miles818 <[email protected]> Co-authored-by: wbrittwage <[email protected]>
1 parent 4eb592b commit b20492e

File tree

3 files changed

+10
-3
lines changed

3 files changed

+10
-3
lines changed

server/controllers/sessionController.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
const fetch = require ('node-fetch');
2+
13
require('dotenv').config();
24
const { Sessions } = require('../models/reactypeModels');
35

@@ -108,7 +110,7 @@ sessionController.gitHubResponse = (req, res, next) => {
108110

109111
sessionController.gitHubSendToken = (req, res, next) => {
110112
const { token } = res.locals;
111-
fetch(`https://api.github.com/user/emails`, {
113+
fetch(`https://api.github.com/user/public_emails`, {
112114
method: 'GET',
113115
headers: {
114116
Accept: 'application/vnd.github.v3+json',

server/controllers/userController.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,16 @@ const randomPassword = () => {
2626
}
2727

2828
userController.createUser = (req, res, next) => {
29-
const { email, username, password } = req.body;
3029

30+
let email, username, password;
3131
// use this condition for Oauth login
3232
if (res.locals.signUpType === 'oauth') {
3333
email = res.locals.githubEmail;
3434
username = email;
3535
password = randomPassword();
36+
res.locals.githubPassword = password;
37+
} else {
38+
({ email, username, password } = req.body);
3639
}
3740

3841
if (!username) {
@@ -82,6 +85,7 @@ userController.createUser = (req, res, next) => {
8285
userController.verifyUser = (req, res, next) => {
8386
let { username, password, isFbOauth } = req.body;
8487
// handle Oauth
88+
console.log('We verifying');
8589
if (res.locals.signUpType === 'oauth') {
8690
username = res.locals.githubEmail;
8791
password = res.locals.githubPassword;

server/models/reactypeModels.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@
1010
*/
1111
const mongoose = require('mongoose');
1212
const bcrypt = require('bcryptjs');
13-
const URI = process.env.NODE_ENV === 'production' ? process.env.URI : process.env.URI;
13+
const URI = process.env.NODE_ENV === 'production' ? process.env.URI : 'mongodb+srv://Daniel:[email protected]/Cluster0?retryWrites=true&w=majority';
14+
// const mongoURI = ('mongodb+srv://Daniel:[email protected]/Cluster0?retryWrites=true&w=majority');
1415

1516
const SALT_WORK_FACTOR = 14;
1617
// connect to mongo db

0 commit comments

Comments
 (0)