package main

import (
	"net/http"
)

// yerelHesap: yerel ayar arayuzunden gelen bir istegin hesabini dogrular. Hesap, istegin kendisinde
// belirtilir (aktif hesaba bakilmaz). Hesap etkin ve oturumu acik olmali; degilse istek reddedilir.
func yerelHesap(w http.ResponseWriter, profil string) (string, bool) {
	if !profilAnahtarDesen.MatchString(profil) {
		http.Error(w, "hesap belirtilmedi", http.StatusBadRequest)
		return "", false
	}
	if !etkinMi(profil) {
		http.Error(w, "bu hesap etkin degil", http.StatusConflict)
		return "", false
	}
	if _, err := oturumOkuProfil(profil); err != nil {
		http.Error(w, "giris gerekli", http.StatusUnauthorized)
		return "", false
	}
	return profil, true
}
