forked from VanshKing30/FoodiesWeb
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request VanshKing30#369 from nishant0708/routes
Feat: routes are Secured in wrong Way And Causing a Lot of problem VanshKing30#356
- Loading branch information
Showing
8 changed files
with
173 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
const passport = require('passport'); | ||
const GoogleStrategy = require('passport-google-oauth20').Strategy; | ||
const User = require('../models/studentLoginInfo'); | ||
const Canteen = require('../models/canteenLoginInfo'); | ||
|
||
passport.use(new GoogleStrategy({ | ||
clientID: process.env.GOOGLE_CLIENT_ID, | ||
clientSecret: process.env.GOOGLE_CLIENT_SECRET, | ||
callbackURL: '/auth/google/callback' | ||
}, | ||
async (accessToken, refreshToken, profile, done) => { | ||
try { | ||
let user = await User.findOne({ googleId: profile.id }); | ||
if (!user) { | ||
user = await User.create({ | ||
googleId: profile.id, | ||
name: profile.displayName, | ||
email: profile.emails[0].value, | ||
}); | ||
} | ||
return done(null, user); | ||
} catch (error) { | ||
return done(error, null); | ||
} | ||
})); | ||
|
||
passport.serializeUser((user, done) => { | ||
done(null, user.id); | ||
}); | ||
|
||
passport.deserializeUser(async (id, done) => { | ||
try { | ||
const user = await User.findById(id); | ||
done(null, user); | ||
} catch (error) { | ||
done(error, null); | ||
} | ||
}); | ||
|
||
module.exports = passport; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
// Modal.js | ||
import React from 'react'; | ||
|
||
const Modal = ({ show, onClose, children }) => { | ||
if (!show) { | ||
return null; | ||
} | ||
|
||
return ( | ||
<div className="fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center"> | ||
<div className="bg-white p-8 rounded shadow-lg w-80"> | ||
<button | ||
className="absolute top-2 right-2 text-gray-600 hover:text-gray-800" | ||
onClick={onClose} | ||
> | ||
× | ||
</button> | ||
{children} | ||
</div> | ||
</div> | ||
); | ||
}; | ||
|
||
export default Modal; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters