@@ -540,8 +540,6 @@ export class DbAuthHandler<
540
540
)
541
541
}
542
542
543
- await this . init ( )
544
-
545
543
const { username } = this . normalizedRequest . jsonBody || { }
546
544
// was the username sent in at all?
547
545
if ( ! username || username . trim ( ) === '' ) {
@@ -640,7 +638,6 @@ export class DbAuthHandler<
640
638
)
641
639
}
642
640
643
- await this . init ( )
644
641
const { username, password } = this . normalizedRequest . jsonBody || { }
645
642
const dbUser = await this . _verifyUser ( username , password )
646
643
const handlerUser = await ( this . options . login as LoginFlowOptions ) . handler (
@@ -670,7 +667,6 @@ export class DbAuthHandler<
670
667
)
671
668
}
672
669
673
- await this . init ( )
674
670
const { password, resetToken } = this . normalizedRequest . jsonBody || { }
675
671
676
672
// is the resetToken present?
@@ -743,7 +739,6 @@ export class DbAuthHandler<
743
739
`Signup flow is not enabled`
744
740
)
745
741
}
746
- await this . init ( )
747
742
748
743
// check if password is valid
749
744
const { password } = this . normalizedRequest . jsonBody || { }
@@ -766,7 +761,6 @@ export class DbAuthHandler<
766
761
}
767
762
768
763
async validateResetToken ( ) {
769
- await this . init ( )
770
764
const { resetToken } = this . normalizedRequest . jsonBody || { }
771
765
// is token present at all?
772
766
if ( ! resetToken || String ( resetToken ) . trim ( ) === '' ) {
@@ -791,7 +785,6 @@ export class DbAuthHandler<
791
785
async webAuthnAuthenticate ( ) {
792
786
const { verifyAuthenticationResponse } = require ( '@simplewebauthn/server' )
793
787
const webAuthnOptions = this . options . webAuthn
794
- await this . init ( )
795
788
796
789
const { rawId } = this . normalizedRequest . jsonBody || { }
797
790
@@ -884,7 +877,6 @@ export class DbAuthHandler<
884
877
if ( this . options . webAuthn === undefined || ! this . options . webAuthn . enabled ) {
885
878
throw new DbAuthError . WebAuthnError ( 'WebAuthn is not enabled' )
886
879
}
887
- await this . init ( )
888
880
889
881
const webAuthnOptions = this . options . webAuthn
890
882
@@ -951,7 +943,6 @@ export class DbAuthHandler<
951
943
if ( ! this . options ?. webAuthn ?. enabled ) {
952
944
throw new DbAuthError . WebAuthnError ( 'WebAuthn is not enabled' )
953
945
}
954
- await this . init ( )
955
946
956
947
const webAuthnOptions = this . options . webAuthn
957
948
@@ -996,7 +987,6 @@ export class DbAuthHandler<
996
987
if ( this . options . webAuthn === undefined || ! this . options . webAuthn . enabled ) {
997
988
throw new DbAuthError . WebAuthnError ( 'WebAuthn is not enabled' )
998
989
}
999
- await this . init ( )
1000
990
1001
991
const user = await this . _getCurrentUser ( )
1002
992
@@ -1237,7 +1227,6 @@ export class DbAuthHandler<
1237
1227
// checks the CSRF token in the header against the CSRF token in the session
1238
1228
// and throw an error if they are not the same (not used yet)
1239
1229
async _validateCsrf ( ) {
1240
- await this . init ( )
1241
1230
if (
1242
1231
this . sessionCsrfToken !== this . normalizedRequest . headers . get ( 'csrf-token' )
1243
1232
) {
@@ -1395,8 +1384,6 @@ export class DbAuthHandler<
1395
1384
1396
1385
// gets the user from the database and returns only its ID
1397
1386
async _getCurrentUser ( ) {
1398
- await this . init ( )
1399
-
1400
1387
if ( ! this . session ?. id ) {
1401
1388
throw new DbAuthError . NotLoggedInError ( )
1402
1389
}
@@ -1431,7 +1418,6 @@ export class DbAuthHandler<
1431
1418
// creates and returns a user, first checking that the username/password
1432
1419
// values pass validation
1433
1420
async _createUser ( ) {
1434
- await this . init ( )
1435
1421
const { username, password, ...userAttributes } =
1436
1422
this . normalizedRequest . jsonBody || { }
1437
1423
if (
@@ -1469,7 +1455,6 @@ export class DbAuthHandler<
1469
1455
1470
1456
// figure out which auth method we're trying to call
1471
1457
async _getAuthMethod ( ) {
1472
- await this . init ( )
1473
1458
// try getting it from the query string, /.redwood/functions/auth?method=[methodName]
1474
1459
let methodName = this . normalizedRequest . query . method as AuthMethodNames
1475
1460
0 commit comments