Skip to content

Commit

Permalink
Updated OAuth --> Working
Browse files Browse the repository at this point in the history
  • Loading branch information
ukataria committed Feb 9, 2024
1 parent fdba63b commit 539f086
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 16 deletions.
4 changes: 2 additions & 2 deletions .env
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
GOOGLE_CLIENT_ID=yourGoogleClientId
GOOGLE_CLIENT_SECRET=yourGoogleClientSecret
MONGO_DB_URI=yourMongoDbUri
SESSION_COOKIE_KEY=yourSessionCookieSecret
MONGO_DB_URI=mongodb://localhost:27017/GlobaLex
SESSION_COOKIE_KEY="hi"
8 changes: 0 additions & 8 deletions public/CallPage.html
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,6 @@ <h3>CALLING...</h3>
<label for="fileInput" style="margin-bottom: 10px;">Choose a file:</label>
<input type="file" id="fileInput" name="file" accept=".wav" style="margin-bottom: 20px;">
<button type="submit" id="Upload" style="padding: 10px; background-color: #2ecc71; color: #fff; border: none; border-radius: 4px; cursor: pointer;">Upload File</button>
<script>
const { spawn } = require('child_process');

document.getElementById('Upload').addEventListener('click', () => {
spawn('node', ['server.js']);
console.log("Reached");
});
</script>
</form>
<script>
function play() {
Expand Down
4 changes: 2 additions & 2 deletions routes/auth.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const bcrypt = require('bcrypt');
const User = require('../models/user');
const router = express.Router();

router.post('/api/register', async (req, res) => {
router.post('/register', async (req, res) => {
try {
const hashedPassword = await bcrypt.hash(req.body.password, 10);
const user = new User({ email: req.body.email, password: hashedPassword });
Expand All @@ -20,7 +20,7 @@ router.post('/api/register', async (req, res) => {
}
});

router.post('/api/login', async (req, res) => {
router.post('/login', async (req, res) => {
const user = await User.findOne({ email: req.body.email });
if (!user) {
return res.status(400).send('Cannot find user');
Expand Down
8 changes: 4 additions & 4 deletions server.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ app.use(express.static(path.join(__dirname, 'public')));
app.use(express.json()); // Parse JSON bodies

// Connect to MongoDB
mongoose.connect('mongodb://localhost:27017/GlobaLex')
mongoose.connect(process.env.MONGO_DB_URI, { useNewUrlParser: true, useUnifiedTopology: true })
.then(() => console.log('Connected to MongoDB'))
.catch(err => console.error('Could not connect to MongoDB:', err));

Expand Down Expand Up @@ -98,11 +98,11 @@ app.use(passport.initialize());
app.use(passport.session());

// Set up routes
app.use('/auth', authRoutes);
app.use('/api', authRoutes);

app.get('/', (req, res) => {
res.sendFile(path.join(__dirname, 'public', 'Login.html'));
});
res.sendFile(path.join(__dirname, 'public', 'Login.html'));
});

app.listen(port, () => {
console.log(`Server listening at http://localhost:${port}`);
Expand Down

0 comments on commit 539f086

Please sign in to comment.