router and auth kk

This commit is contained in:
breel
2020-08-08 10:18:17 -06:00
parent 1a06d9634b
commit c145bd9daf
5 changed files with 53 additions and 31 deletions

View File

@@ -2,6 +2,7 @@ package auth
import (
"context"
"errors"
"local/dndex/storage"
"local/dndex/storage/entity"
"net/http"
@@ -27,6 +28,9 @@ func Generate(g storage.RateLimitedGraph, r *http.Request, salt string) (string,
func generateToken(g storage.RateLimitedGraph, r *http.Request) (Token, string, error) {
namespaceRequested := readRequestedNamespace(r)
if namespaceRequested == "" {
return Token{}, "", errors.New("no namespace found")
}
key, err := getKeyForNamespace(r.Context(), g, namespaceRequested)
if err != nil {
return Token{}, "", err