Подключение Postgresql и redis

This commit is contained in:
2026-10-30 15:04:31 +03:00
parent e70fd2bb61
commit 712a359866
46 changed files with 2509 additions and 208 deletions
+5 -12
View File
@@ -172,19 +172,12 @@ func jsonFieldNames(dst any) (map[string]struct{}, bool) {
return names, true
}
func (a *API) authenticate(w http.ResponseWriter, r *http.Request) (store.User, bool) {
raw := strings.TrimSpace(r.Header.Get("X-User-Id"))
id, ok := canonicalUUID(raw)
if !ok {
a.fail(w, r, http.StatusUnauthorized, "unauthorized", "Нет действительной идентификации", 0)
return store.User{}, false
func validPassword(s string) bool {
if !utf8.ValidString(s) {
return false
}
user, exists := a.store.User(id)
if !exists {
a.fail(w, r, http.StatusUnauthorized, "unauthorized", "Нет действительной идентификации", 0)
return store.User{}, false
}
return user, true
n := utf8.RuneCountInString(s)
return n >= 12 && n <= 128 && strings.TrimSpace(s) != ""
}
func (a *API) pageQuery(w http.ResponseWriter, r *http.Request, scope string) (int, *store.Cursor, bool) {