Skip to content

Commit

Permalink
debugginh
Browse files Browse the repository at this point in the history
  • Loading branch information
kamadi2000 committed Nov 1, 2023
1 parent b207065 commit e0292f8
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions backend/src/controllers/authController.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ const jwt = require("jsonwebtoken");
const { GenerateRandomPassword } = require("../utils/string");
const emailModule = require("../utils/email");
const { OTPGenerator } = require("../utils/otpgenerator");
const { default: axios } = require("axios");


require("dotenv").config();
const signup = async (req, res, isWeb) => {
Expand Down Expand Up @@ -137,19 +139,16 @@ const googleLoginBase = async (req, res, isWeb) => {
const { token } = req.body;
console.log({ token });
//verfication of user by fetching user information from google
const googleResponse = await fetch(
const googleResponse = await axios.get(
"https://www.googleapis.com/oauth2/v3/userinfo",
{
method: "GET",
headers: {
Authorization: `Bearer ${token}`,
Accept: "application/json",
},
}
).then((res) => res.json());

console.log(googleResponse);
const { email, name } = googleResponse;
)
console.log(googleResponse.data);
const { email, name } = googleResponse.data;
//see if there is an user with that email already
const user = await User.findOne({ email });
console.log({ email, name });
Expand Down Expand Up @@ -197,8 +196,9 @@ const googleLoginBase = async (req, res, isWeb) => {
process.env.SECURITY_KEY,
{ expiresIn: "5hour" }
);
res.cookie("token", newToken);
res.json({ message: "Login successful" });
// res.cookie("token", newToken);

res.json({ message: "Login successful" , newToken });
}
// Send the token in the response
} catch (error) {
Expand Down

0 comments on commit e0292f8

Please sign in to comment.