package dbhandler import ( "context" "git.acooldomain.co/server-manager/backend/models" "golang.org/x/crypto/bcrypt" ) func HashPassword(password string) (string, error) { bytes, err := bcrypt.GenerateFromPassword([]byte(password), bcrypt.DefaultCost) return string(bytes), err } type InviteToken struct { Email string Permissions models.Permission Token string } type UserSignupRequest struct { Token InviteToken Username string Password string } type UserPassAuthanticationDbHandler interface { // Read Only AuthenticateUser(ctx context.Context, username string, password string) (*models.User, error) ListUsers(ctx context.Context) ([]models.User, error) CountUsers(ctx context.Context) (uint, error) // Write CreateUser(ctx context.Context, username string, password string, permissions models.Permission, email string, maxOwnedServers uint) error RemoveUser(ctx context.Context, username string) error SetPermissions(ctx context.Context, username string, permissions models.Permission) error SetPassword(ctx context.Context, username string, password string) error } type InviteTokenDbHandler interface { SaveInviteToken(ctx context.Context, email string, permissions models.Permission) (string, error) GetInviteToken(ctx context.Context, token string) (*InviteToken, error) DeleteInviteToken(ctx context.Context, token string) error }