package utils import ( "context" "crypto/sha1" "fmt" "gorm.io/gorm" "sonarqube-badge/store" ) func UserExists(ctx context.Context, email string, password string) bool { db := ctx.Value("db").(*gorm.DB) passwordHash := sha1.Sum([]byte(password)) user := store.User{} db.Where("email = ? AND password = ?", email, fmt.Sprintf("%x", passwordHash)).First(&user) return user.ID != 0 } func GetUser(ctx context.Context, email string) *store.User { db := ctx.Value("db").(*gorm.DB) user := store.User{} db.Where("email = ?", email).First(&user) return &user }