feat(api): auth-хендлеры register/login/logout/me + session cookie

This commit is contained in:
2026-07-03 20:11:00 +07:00
parent a584cf5c37
commit aa0ef1c6a9
4 changed files with 473 additions and 5 deletions
+38 -1
View File
@@ -1,6 +1,43 @@
package api
import "github.com/vasyakrg/dns-autoresolver/internal/diff"
import (
"github.com/vasyakrg/dns-autoresolver/internal/diff"
"github.com/vasyakrg/dns-autoresolver/internal/store"
)
type registerRequest struct {
Email string `json:"email"`
Password string `json:"password"`
}
type loginRequest struct {
Email string `json:"email"`
Password string `json:"password"`
}
// userResponse and projectResponse deliberately expose only id/email and
// id/name — password_hash must never reach a client response.
type userResponse struct {
ID string `json:"id"`
Email string `json:"email"`
}
type projectResponse struct {
ID string `json:"id"`
Name string `json:"name"`
}
type authResponse struct {
User userResponse `json:"user"`
Project projectResponse `json:"project"`
}
func toAuthResponse(u store.User, p store.Project) authResponse {
return authResponse{
User: userResponse{ID: u.ID.String(), Email: u.Email},
Project: projectResponse{ID: p.ID.String(), Name: p.Name},
}
}
type applyRequest struct {
ApplyUpdates bool `json:"applyUpdates"`