package models

import "sync"

type User struct {
	Username string
	Password string
	Email    string
}

var (
	usersMu sync.RWMutex
	users   = map[string]User{}
)

func CreateUser(username, password, email string) {
	usersMu.Lock()
	defer usersMu.Unlock()
	users[username] = User{Username: username, Password: password, Email: email}
}

func GetUser(username string) (User, bool) {
	usersMu.RLock()
	defer usersMu.RUnlock()
	user, ok := users[username]
	return user, ok
}

func ValidateUser(username, password string) bool {
	usersMu.RLock()
	defer usersMu.RUnlock()
	user, ok := users[username]
	return ok && user.Password == password
}
