feat: make app configurable

This commit is contained in:
Stavros
2025-01-19 15:04:46 +02:00
parent c0e085ea10
commit 6eccb6d835
11 changed files with 299 additions and 40 deletions

21
internal/auth/auth.go Normal file
View File

@@ -0,0 +1,21 @@
package auth
import (
"tinyauth/internal/types"
"golang.org/x/crypto/bcrypt"
)
func FindUser(userList types.UserList, username string) (*types.User) {
for _, user := range userList.Users {
if user.Username == username {
return &user
}
}
return nil
}
func CheckPassword(user types.User, password string) bool {
hashedPasswordErr := bcrypt.CompareHashAndPassword([]byte(user.Password), []byte(password))
return hashedPasswordErr == nil
}