Skip to content

Commit

Permalink
Merge pull request #36 from cornell-dti/ks/fix-heroku-auth
Browse files Browse the repository at this point in the history
Adjust server routes to work in production
  • Loading branch information
karunsingh authored Mar 8, 2018
2 parents 82be5a3 + 35ef758 commit 6941e87
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion client/src/components/pages/LoginView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class LoginView extends React.Component {
Queue up for office hours remotely. <br /> Skip the wait line
</section>
<p className="hintText" >Use your Cornell NetID to login</p>
<LoginButton URL="/auth" />
<LoginButton URL="/__auth" />
<img src={QLogo} className="QLogo" />
</div >
);
Expand Down
10 changes: 5 additions & 5 deletions server/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ passport.use(new GoogleStrategy(
{
clientID: "694487664328-79nbgbrnm3n3sa3nfsdfm5jigkr69svp.apps.googleusercontent.com",
clientSecret: process.env.OH_GOOGLE_SECRET,
callbackURL: "/auth/callback",
callbackURL: "/__auth/callback",
userProfileURL: "https://www.googleapis.com/oauth2/v3/userinfo",
},
function (accessToken, refreshToken, profile, cb) {
Expand All @@ -58,15 +58,15 @@ passport.deserializeUser(function (user, done) {
done(null, user)
})

app.get('/auth',
app.get('/__auth',
passport.authenticate('google', {
scope: ['email'],
// @ts-ignore: Hosted domain is used by the Google strategy, but not allowed in passport's types
hostedDomain: "cornell.edu"
})
)

app.get('/auth/callback',
app.get('/__auth/callback',
passport.authenticate('google', { failureRedirect: '/login' }),
function (req, res) {
console.log("Callback:")
Expand All @@ -75,10 +75,9 @@ app.get('/auth/callback',
}
)

app.get('/sess',
app.get('/__sess',
function (req, res) {
console.log("####################")

console.log("Session Test:")
console.log(req.user)
if (req.user == undefined) {
Expand All @@ -89,6 +88,7 @@ app.get('/sess',
)

app.use(express.static('../client/build'));
app.use('*', express.static('../client/build/index.html'));

app.listen(process.env.PORT || 3001, () => {
console.log("Now listening on port " + (process.env.PORT || 3001));
Expand Down

0 comments on commit 6941e87

Please sign in to comment.