func (h *HandlersAdmin) LoginPOSTHandler(w http.ResponseWriter, r *http.Request) {
	h.Inc(metricAdminReq)
	utils.DebugHTTPDump(r, h.Settings.DebugHTTP(settings.ServiceAdmin), false)
	var l LoginRequest
	if h.Settings.DebugService(settings.ServiceAdmin) {
		log.Println("DebugService: Decoding POST body")
	}
	if err := json.NewDecoder(r.Body).Decode(&l); err != nil {
		adminErrorResponse(w, "error parsing POST body", http.StatusInternalServerError, err)
		h.Inc(metricAdminErr)
		return
	}
	access, user := h.Users.CheckLoginCredentials(l.Username, l.Password)
	if !access {
		adminErrorResponse(w, "invalid credentials", http.StatusForbidden, nil)
		h.Inc(metricAdminErr)
		return
	}
	permissions, err := h.Users.ConvertPermissions(user.Permissions.RawMessage)
	if err != nil {
		adminErrorResponse(w, "error processing login", http.StatusInternalServerError, err)
		h.Inc(metricAdminErr)
		return
	}
	_, err = h.Sessions.Save(r, w, user, permissions)
	if err != nil {
		adminErrorResponse(w, "session error", http.StatusForbidden, err)
		h.Inc(metricAdminErr)
		return
	}
	if h.Settings.DebugService(settings.ServiceAdmin) {
		log.Println("DebugService: Login response sent")
	}
	adminOKResponse(w, "/environment/"+user.DefaultEnv+"/active")
	h.Inc(metricAdminOK)
}
LoginPOSTHandler for login page for POST requests
package handlers
import (
	"encoding/base64"
	"encoding/json"
	"fmt"
	"log"
	"net/http"
	"github.com/gorilla/mux"
	"github.com/jmpsec/osctrl/admin/sessions"
	"github.com/jmpsec/osctrl/environments"
	"github.com/jmpsec/osctrl/nodes"
	"github.com/jmpsec/osctrl/queries"
	"github.com/jmpsec/osctrl/settings"
	"github.com/jmpsec/osctrl/users"
	"github.com/jmpsec/osctrl/utils"
)