diff --git a/api/auth/me.go b/api/auth/me.go new file mode 100644 index 0000000..b83384b --- /dev/null +++ b/api/auth/me.go @@ -0,0 +1,42 @@ +package api_auth + +import ( + "net/http" + + "git.oblat.lv/alex/triggerssmith/internal/server" +) + +type meResponse struct { + UserID uint `json:"id"` + Username string `json:"username"` + Email string `json:"email"` +} + +func (h *authHandler) handleMe(w http.ResponseWriter, r *http.Request) { + server.NotImplemented(w) + // refresh_token_cookie, err := r.Cookie("refresh_token") + // if err != nil { + // w.WriteHeader(http.StatusUnauthorized) + // return + // } + // userID, err := h.a.ValidateRefreshToken(refresh_token_cookie.Value) + // if err != nil { + // w.WriteHeader(http.StatusUnauthorized) + // return + // } + // user, err := h.a.Get("id", fmt.Sprint(userID)) + // if err != nil { + // http.Error(w, "Failed to get user", http.StatusInternalServerError) + // return + // } + // w.Header().Set("Content-Type", "application/json") + // err = json.NewEncoder(w).Encode(meResponse{ + // UserID: user.ID, + // Username: user.Username, + // Email: user.Email, + // }) + // if err != nil { + // http.Error(w, "Failed to encode response", http.StatusInternalServerError) + // return + // } +}