This commit is contained in:
+5
-12
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user