From be7a54e7f43d7690c125f68ed5febf99a808de9b Mon Sep 17 00:00:00 2001 From: Ethan Wellenreiter Date: Thu, 1 May 2025 23:08:48 -0400 Subject: [PATCH] storage/auth checkpoint Signed-off-by: Ethan Wellenreiter --- backend/internal/storage/auth/storage.go | 10 +++++----- backend/internal/storage/auth/users.go | 1 + 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/backend/internal/storage/auth/storage.go b/backend/internal/storage/auth/storage.go index 254eca9..e6b19f8 100644 --- a/backend/internal/storage/auth/storage.go +++ b/backend/internal/storage/auth/storage.go @@ -10,9 +10,9 @@ type AuthStorage struct { GetByID(ctx context.Context, id int64) (*User, error) GetByEmail(context.Context, string) (*User, error) GetByUsername(context.Context, string) (*User, error) - Create(context.Context, *User) error // create a non-exported create function which does take in the tx - CreateAndInvite(ctx context.Context, user *User, token string, exp time.Duration) error - Activate(context.Context, string) error + Create(context.Context, *User) error // create a non-exported create function which does take in the tx + CreateAndInvite(ctx context.Context, user *User, token string, exp time.Duration) error // figure this out + Activate(context.Context, string) error // what does this do? Delete(ctx context.Context, id int64) error UpdateUserPass(ctx context.Context, user string, oldPassword string, newPass string) error @@ -26,13 +26,13 @@ type AuthStorage struct { AddSession(ctx context.Context, userid int64) (token string, err error) CheckSession(ctx context.Context, token string) (valid bool, userid int64, err error) // should also extend it by the lifespan if near the end of the time. maybe a 5 min window at the end? RemoveSession(ctx context.Context, token string) error - SetLifespan(ctx context.Context, token string, lf time.Time) error + // SetLifespan(ctx context.Context, token string, lf time.Time) error } CSRF interface { AddCSRF(ctx context.Context, sessionToken string) (csrftoken string, err error) + CheckCSRF(ctx context.Context, sessionToken string, csrfToken string) (bool, error) RemoveCSRF(ctx context.Context, sessionToken string) error - ValidCSRF(ctx context.Context, sessionToken string, csrfToken string) (bool, error) // CleanupCSRF() } diff --git a/backend/internal/storage/auth/users.go b/backend/internal/storage/auth/users.go index 87b59d0..b973116 100644 --- a/backend/internal/storage/auth/users.go +++ b/backend/internal/storage/auth/users.go @@ -18,6 +18,7 @@ type User struct { CreatedAt string `json:"created_at"` IsActive bool `json:"is_active"` Role Role `json:"role"` + Groups []int64 `json:"groups"` } type Password struct {