Adding/changing function declarations for Users storage interface

Signed-off-by: Ethan Wellenreiter <ewellenreiter@gmail.com>
This commit is contained in:
Ethan Wellenreiter 2025-05-10 01:32:00 -04:00
parent 91cfa901ca
commit 5e6d061330
2 changed files with 29 additions and 17 deletions

View File

@ -181,12 +181,17 @@ func (s *SQLUsersStore) Create(ctx context.Context, user *User) error { // creat
})
}
func (s *SQLUsersStore) CreateAndInvite(ctx context.Context, user *User, token string, exp time.Duration) error { // figure this out
func (s *SQLUsersStore) CreateAndInvite(ctx context.Context, user *User, token string, exp time.Duration) error {
// Implement the logic to create a user and invite them using the provided token with an expiration date.
return nil
}
func (s *SQLUsersStore) Activate(context.Context, string) error { // what does this do?
return nil
func (s *SQLUsersStore) Invite(ctx context.Context, exp time.Duration) (int64, string, error) {
return -1, "", nil
}
func (s *SQLUsersStore) CreateFromInvite(ctx context.Context, user *User) error {
// Implement the logic to create a user from an invite, possibly accepting terms of service or other conditions.
}
func (s *SQLUsersStore) delete(ctx context.Context, id int64, tx *sql.Tx) error {
@ -218,14 +223,13 @@ func (s *SQLUsersStore) Delete(ctx context.Context, id int64) error {
})
}
func (s *SQLUsersStore) UpdateUserPass(ctx context.Context, user string, oldPassword string, newPass string) error {
return nil
}
// func (s *SQLUsersStore) UpdateUserPass(ctx context.Context, user string, oldPassword string, newPass string) error {
// // Implement the logic to update a user's password if the old password matches and is correct.
// return nil
// }
func (s *SQLUsersStore) CheckPass(ctx context.Context, name string, pass string) (bool, error) {
return false, nil
}
func (s *SQLUsersStore) SigninUser(ctx context.Context, name string, pass string) (bool, *User, error) {
// CheckPass(ctx context.Context, name string, pass string) (bool, error)
func (s *SQLUsersStore) VerifyUserCredentials(ctx context.Context, username string, pass string) (bool, *User, error) {
// Implement the logic to verify user credentials and return a boolean indicating success or failure along with the User details if successful.
return false, nil, nil
}

View File

@ -19,16 +19,24 @@ type Storage 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 // figure this out
Activate(context.Context, string) error // what does this do?
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
Invite(ctx context.Context, exp time.Duration) (int64, string, error)
CreateFromInvite(ctx context.Context, user *User) error
Activate(context.Context, string) error
Delete(ctx context.Context, id int64) error
UpdateUserPass(ctx context.Context, user string, oldPassword string, newPass string) error
// UpdateUserPass(ctx context.Context, user string, oldPassword string, newPass string) error
// Look into resetting user passwords later
// CheckPass(ctx context.Context, name string, pass string) (bool, error)
// SigninUser(ctx context.Context, name string, pass string) (bool, *User, error)
VerifyUserCredentials(ctx context.Context, username string, pass string) (bool, *User, error)
// ValidCredentials(ctx context.Context, user *User, pass string) (bool, error)
// Figure out how to do user invites (so user account isn't truly made, no email, username, or password) and also how to do account creation with activation
// have createandinvite to do the activation stuff. so createandinvite -> activate does that process
// use createandinvite to create a blank user have a createFromInvite which takes a *User and adds everything but the id to the database. this should then send an activation link and do the activation. so a two stepper
}
Sessions interface { // store just session tokens, and their corresponding user id
@ -75,6 +83,6 @@ type Storage struct {
func NewSQLRedisMinIOStorage(db *sql.DB) Storage {
return Storage{
Users: &SQLUsersStore{db},
// Users: &SQLUsersStore{db},
}
}