1-
2-
31import bcrypt from "bcryptjs" ;
42import crypto from "crypto" ;
53import { Request , Response } from "express" ;
@@ -421,7 +419,7 @@ export class Users {
421419 await this . userService . updateUser ( userId , username . trim ( ) ) ;
422420 await this . createLog ( req , "changeUsername" , "users" , 200 , userId ) ;
423421 res . status ( 200 ) . send ( { message : "Username updated" } ) ;
424- } catch ( error ) {
422+ } catch {
425423 await this . createLog ( req , "changeUsername" , "users" , 500 , userId ) ;
426424 this . sendError ( res , 500 , "Error updating username" ) ;
427425 }
@@ -475,7 +473,7 @@ export class Users {
475473 await this . userService . updateUserPassword ( userId , hashedPassword ) ;
476474 await this . createLog ( req , "changePassword" , "users" , 200 , userId ) ;
477475 res . status ( 200 ) . send ( { message : "Password changed successfully" } ) ;
478- } catch ( error ) {
476+ } catch {
479477 await this . createLog ( req , "changePassword" , "users" , 500 , userId ) ;
480478 this . sendError ( res , 500 , "Error changing password" ) ;
481479 }
@@ -529,7 +527,7 @@ export class Users {
529527 res
530528 . status ( 200 )
531529 . send ( { message : "Password reset successfully" , token : jwtToken } ) ;
532- } catch ( error ) {
530+ } catch {
533531 await this . createLog ( req , "resetPassword" , "users" , 500 , user . user_id ) ;
534532 this . sendError ( res , 500 , "Error resetting password" ) ;
535533 }
@@ -656,7 +654,7 @@ export class Users {
656654 } ) ;
657655 await this . createLog ( req , "searchUsers" , "users" , 200 ) ;
658656 res . send ( users . map ( ( user ) => this . mapUserSearch ( user ) ) ) ;
659- } catch ( error ) {
657+ } catch {
660658 await this . createLog ( req , "searchUsers" , "users" , 500 ) ;
661659 this . sendError ( res , 500 , "Error searching users" ) ;
662660 }
@@ -688,7 +686,7 @@ export class Users {
688686 public async getUser ( req : Request , res : Response ) {
689687 try {
690688 await userIdParamValidator . validate ( req . params ) ;
691- } catch ( err ) {
689+ } catch {
692690 await this . createLog ( req , "getUser" , "users" , 400 ) ;
693691 return this . sendError ( res , 400 , "Invalid userId" ) ;
694692 }
@@ -758,7 +756,7 @@ export class Users {
758756 req . user . user_id ,
759757 ) ;
760758 res . send ( users . map ( ( user ) => this . mapUserSearch ( user ) ) ) ;
761- } catch ( error ) {
759+ } catch {
762760 await this . createLog (
763761 req ,
764762 "adminSearchUsers" ,
@@ -838,7 +836,7 @@ export class Users {
838836 }
839837 try {
840838 await userIdParamValidator . validate ( req . params ) ;
841- } catch ( err ) {
839+ } catch {
842840 await this . createLog (
843841 req ,
844842 "adminGetUser" ,
@@ -888,7 +886,8 @@ export class Users {
888886 @httpPost ( "/transfer-credits" , LoggedCheck . middleware )
889887 public async transferCredits ( req : AuthenticatedRequest , res : Response ) {
890888 const { targetUserId, amount } = req . body ;
891- if ( ! targetUserId || isNaN ( amount ) || amount <= 0 ) {
889+ const transferAmount = Number ( amount ) ;
890+ if ( ! targetUserId || isNaN ( transferAmount ) || transferAmount <= 0 ) {
892891 await this . createLog (
893892 req ,
894893 "transferCredits" ,
@@ -925,7 +924,7 @@ export class Users {
925924 ) ;
926925 return this . sendError ( res , 404 , "Recipient not found" ) ;
927926 }
928- if ( sender . balance < amount ) {
927+ if ( sender . balance < transferAmount ) {
929928 await this . createLog (
930929 req ,
931930 "transferCredits" ,
@@ -937,11 +936,11 @@ export class Users {
937936 }
938937 await this . userService . updateUserBalance (
939938 sender . user_id ,
940- sender . balance - Number ( amount ) ,
939+ sender . balance - transferAmount ,
941940 ) ;
942941 await this . userService . updateUserBalance (
943942 recipient . user_id ,
944- recipient . balance + Number ( amount ) ,
943+ recipient . balance + transferAmount ,
945944 ) ;
946945 await this . createLog (
947946 req ,
@@ -951,7 +950,7 @@ export class Users {
951950 sender . user_id ,
952951 ) ;
953952 res . status ( 200 ) . send ( { message : "Credits transferred" } ) ;
954- } catch ( error ) {
953+ } catch {
955954 await this . createLog (
956955 req ,
957956 "transferCredits" ,
@@ -1030,7 +1029,7 @@ export class Users {
10301029 } ) ;
10311030 await this . createLog ( req , "changeRole" , "users" , 200 , userId ) ;
10321031 return res . status ( 200 ) . send ( { message : "Role updated successfully" } ) ;
1033- } catch ( error ) {
1032+ } catch {
10341033 await this . createLog ( req , "changeRole" , "users" , 500 , userId ) ;
10351034 this . sendError ( res , 500 , "Error setting role cookie" ) ;
10361035 }
@@ -1055,7 +1054,7 @@ export class Users {
10551054 email : userData . email ,
10561055 username : userData . username ,
10571056 } ;
1058- } catch ( error ) {
1057+ } catch {
10591058 throw new Error ( "Failed to verify Discord token" ) ;
10601059 }
10611060 }
@@ -1076,7 +1075,7 @@ export class Users {
10761075 email : userData . email ,
10771076 username : userData . name ,
10781077 } ;
1079- } catch ( error ) {
1078+ } catch {
10801079 throw new Error ( "Failed to verify Google token" ) ;
10811080 }
10821081 }
0 commit comments