@@ -350,8 +350,7 @@ router.get("/google", (req, res) => {
350
350
router . get (
351
351
"/google/callback" ,
352
352
requireSignIn ,
353
- async ( req : Request , res ) => {
354
- const authenticatedReq = req as AuthenticatedRequest ;
353
+ async ( req : AuthenticatedRequest , res ) => {
355
354
const { code, state } = req . query ;
356
355
try {
357
356
if ( ! state ) {
@@ -377,12 +376,12 @@ router.get(
377
376
return res . status ( 400 ) . json ( { message : "Email not found" } ) ;
378
377
}
379
378
380
- if ( ! authenticatedReq . user ) {
379
+ if ( ! req . user ) {
381
380
return res . status ( 401 ) . send ( { error : "Unauthorized" } ) ;
382
381
}
383
382
384
383
// Get the currently authenticated user (from `requireSignIn`)
385
- let user = await User . findOne ( { where : { id : authenticatedReq . user . id } } ) ;
384
+ let user = await User . findOne ( { where : { id : req . user . id } } ) ;
386
385
387
386
if ( ! user ) {
388
387
return res . status ( 400 ) . json ( { message : "User not found" } ) ;
@@ -460,13 +459,12 @@ router.get(
460
459
router . post (
461
460
"/gsheets/data" ,
462
461
requireSignIn ,
463
- async ( req : Request , res ) => {
464
- const authenticatedReq = req as AuthenticatedRequest ;
462
+ async ( req : AuthenticatedRequest , res ) => {
465
463
const { spreadsheetId, robotId } = req . body ;
466
- if ( ! authenticatedReq . user ) {
464
+ if ( ! req . user ) {
467
465
return res . status ( 401 ) . send ( { error : "Unauthorized" } ) ;
468
466
}
469
- const user = await User . findByPk ( authenticatedReq . user . id , { raw : true } ) ;
467
+ const user = await User . findByPk ( req . user . id , { raw : true } ) ;
470
468
471
469
if ( ! user ) {
472
470
return res . status ( 400 ) . json ( { message : "User not found" } ) ;
@@ -578,14 +576,13 @@ router.post("/gsheets/update", requireSignIn, async (req, res) => {
578
576
router . post (
579
577
"/gsheets/remove" ,
580
578
requireSignIn ,
581
- async ( req : Request , res ) => {
582
- const authenticatedReq = req as AuthenticatedRequest ;
579
+ async ( req : AuthenticatedRequest , res ) => {
583
580
const { robotId } = req . body ;
584
581
if ( ! robotId ) {
585
582
return res . status ( 400 ) . json ( { message : "Robot ID is required" } ) ;
586
583
}
587
584
588
- if ( ! authenticatedReq . user ) {
585
+ if ( ! req . user ) {
589
586
return res . status ( 401 ) . send ( { error : "Unauthorized" } ) ;
590
587
}
591
588
@@ -607,7 +604,7 @@ router.post(
607
604
} ) ;
608
605
609
606
capture ( "maxun-oss-google-sheet-integration-removed" , {
610
- user_id : authenticatedReq . user . id ,
607
+ user_id : req . user . id ,
611
608
robot_id : robotId ,
612
609
deleted_at : new Date ( ) . toISOString ( ) ,
613
610
} ) ;
0 commit comments