refactor, sketch SSE implementation

This commit is contained in:
Carl Pearson
2024-10-19 06:02:54 -06:00
parent 459e899efe
commit 22a82d0e4c
11 changed files with 266 additions and 124 deletions

21
users/user.go Normal file
View File

@@ -0,0 +1,21 @@
package users
import (
"golang.org/x/crypto/bcrypt"
"gorm.io/gorm"
)
type User struct {
gorm.Model
Username string `gorm:"unique"`
Password string
}
func Create(db *gorm.DB, username, password string) error {
hashedPassword, _ := bcrypt.GenerateFromPassword([]byte(password), bcrypt.DefaultCost)
user := User{Username: username, Password: string(hashedPassword)}
if err := db.Create(&user).Error; err != nil {
return err
}
return nil
}