diff options
| author | nsfisis <nsfisis@gmail.com> | 2025-03-04 23:39:26 +0900 |
|---|---|---|
| committer | nsfisis <nsfisis@gmail.com> | 2025-03-04 23:39:26 +0900 |
| commit | efd34b970d0d1f88fa7d7e9d69e569f039867ca2 (patch) | |
| tree | ba1e5a51e2fac9ecbe7b9b3e0e197bdb327f2a4e /backend/auth/auth.go | |
| parent | bd9c2e8b587c733059d44f642c53536eb7fe1ec9 (diff) | |
| download | phperkaigi-2025-albatross-efd34b970d0d1f88fa7d7e9d69e569f039867ca2.tar.gz phperkaigi-2025-albatross-efd34b970d0d1f88fa7d7e9d69e569f039867ca2.tar.zst phperkaigi-2025-albatross-efd34b970d0d1f88fa7d7e9d69e569f039867ca2.zip | |
rm registration token
Diffstat (limited to 'backend/auth/auth.go')
| -rw-r--r-- | backend/auth/auth.go | 28 |
1 files changed, 2 insertions, 26 deletions
diff --git a/backend/auth/auth.go b/backend/auth/auth.go index b23884f..f4c5931 100644 --- a/backend/auth/auth.go +++ b/backend/auth/auth.go @@ -15,9 +15,7 @@ import ( ) var ( - ErrInvalidRegistrationToken = errors.New("invalid registration token") - ErrNoRegistrationToken = errors.New("no registration token") - ErrForteeLoginTimeout = errors.New("fortee login timeout") + ErrForteeLoginTimeout = errors.New("fortee login timeout") ) const ( @@ -29,7 +27,6 @@ func Login( queries *db.Queries, username string, password string, - registrationToken *string, ) (int, error) { userAuth, err := queries.GetUserAuthByUsername(ctx, username) if err != nil && !errors.Is(err, pgx.ErrNoRows) { @@ -50,7 +47,7 @@ func Login( } // Authenticate with fortee. - return verifyForteeAccountOrSignup(ctx, queries, username, password, registrationToken) + return verifyForteeAccountOrSignup(ctx, queries, username, password) } func verifyForteeAccountOrSignup( @@ -58,7 +55,6 @@ func verifyForteeAccountOrSignup( queries *db.Queries, username string, password string, - registrationToken *string, ) (int, error) { canonicalizedUsername, err := verifyForteeAccount(ctx, username, password) if err != nil { @@ -71,7 +67,6 @@ func verifyForteeAccountOrSignup( ctx, queries, canonicalizedUsername, - registrationToken, ) } return 0, err @@ -83,12 +78,7 @@ func signup( ctx context.Context, queries *db.Queries, username string, - registrationToken *string, ) (int, error) { - if err := verifyRegistrationToken(ctx, queries, registrationToken); err != nil { - return 0, err - } - // TODO: transaction userID, err := queries.CreateUser(ctx, username) if err != nil { @@ -110,20 +100,6 @@ func signup( return int(userID), nil } -func verifyRegistrationToken(ctx context.Context, queries *db.Queries, registrationToken *string) error { - if registrationToken == nil { - return ErrNoRegistrationToken - } - exists, err := queries.IsRegistrationTokenValid(ctx, *registrationToken) - if err != nil { - return err - } - if !exists { - return ErrInvalidRegistrationToken - } - return nil -} - func verifyForteeAccount(ctx context.Context, username string, password string) (string, error) { ctx, cancel := context.WithTimeout(ctx, forteeAPITimeout) defer cancel() |
