Merge pull request #142 from getmaxun/google-oauth-redirect

fix: google oauth redirect
This commit is contained in:
Karishma Shukla
2024-11-09 22:38:31 +05:30
committed by GitHub
4 changed files with 119 additions and 94 deletions

View File

@@ -341,12 +341,14 @@ router.get('/google/callback', requireSignIn, async (req: AuthenticatedRequest,
const jwtToken = jwt.sign({ userId: user.id }, process.env.JWT_SECRET as string, { expiresIn: '12h' });
res.cookie('token', jwtToken, { httpOnly: true });
res.json({
message: 'Google authentication successful',
google_sheet_email: robot.google_sheet_email,
jwtToken,
files
});
// res.json({
// message: 'Google authentication successful',
// google_sheet_email: robot.google_sheet_email,
// jwtToken,
// files
// });
res.redirect(`http://localhost:5173`);
} catch (error: any) {
res.status(500).json({ message: `Google OAuth error: ${error.message}` });
}

View File

@@ -21,38 +21,39 @@ minioClient.bucketExists('maxun-test')
console.error('Error connecting to MinIO:', err);
})
async function createBucketWithPolicy(bucketName: string, policy?: 'public-read' | 'private') {
async function createBucketWithPolicy(bucketName: string, policy = 'public-read') {
try {
const bucketExists = await minioClient.bucketExists(bucketName);
if (!bucketExists) {
await minioClient.makeBucket(bucketName);
console.log(`Bucket ${bucketName} created successfully.`);
if (policy === 'public-read') {
// Define a public-read policy
const policyJSON = {
Version: "2012-10-17",
Statement: [
{
Effect: "Allow",
Principal: "",
Action: ["s3:GetObject"],
Resource: [`arn:aws:s3:::${bucketName}/*`]
}
]
};
await minioClient.setBucketPolicy(bucketName, JSON.stringify(policyJSON));
console.log(`Public-read policy applied to bucket ${bucketName}.`);
}
} else {
console.log(`Bucket ${bucketName} already exists.`);
}
if (policy === 'public-read') {
// Apply public-read policy after confirming the bucket exists
const policyJSON = {
Version: "2012-10-17",
Statement: [
{
Effect: "Allow",
Principal: "*",
Action: ["s3:GetObject"],
Resource: [`arn:aws:s3:::${bucketName}/*`]
}
]
};
await minioClient.setBucketPolicy(bucketName, JSON.stringify(policyJSON));
console.log(`Public-read policy applied to bucket ${bucketName}.`);
}
} catch (error) {
console.error('Error in bucket creation or policy application:', error);
}
}
class BinaryOutputService {
private bucketName: string;