1
0
mirror of https://github.com/muety/wakapi.git synced 2023-08-10 21:12:56 +03:00

chore: write authenticated user to logs and sentry

This commit is contained in:
Ferdinand Mütsch
2021-03-26 13:10:10 +01:00
parent 01d51b78b1
commit 2b57da224c
17 changed files with 478 additions and 346 deletions

View File

@ -53,7 +53,7 @@ func (h *HeartbeatApiHandler) RegisterRoutes(router *mux.Router) {
// @Router /heartbeat [post]
func (h *HeartbeatApiHandler) Post(w http.ResponseWriter, r *http.Request) {
var heartbeats []*models.Heartbeat
user := r.Context().Value(models.UserKey).(*models.User)
user := middlewares.GetPrincipal(r)
opSys, editor, _ := utils.ParseUserAgent(r.Header.Get("User-Agent"))
machineName := r.Header.Get("X-Machine-Name")

View File

@ -68,7 +68,7 @@ func (h *MetricsHandler) RegisterRoutes(router *mux.Router) {
}
func (h *MetricsHandler) Get(w http.ResponseWriter, r *http.Request) {
reqUser := r.Context().Value(models.UserKey).(*models.User)
reqUser := middlewares.GetPrincipal(r)
if reqUser == nil {
w.WriteHeader(http.StatusUnauthorized)
w.Write([]byte(conf.ErrUnauthorized))