add me method (not implemented)
This commit is contained in:
42
api/auth/me.go
Normal file
42
api/auth/me.go
Normal file
@@ -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
|
||||||
|
// }
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user