code: func (service *Service) ProcessTOTPConfirmation(w http.ResponseWriter, request *http.Request) {
  	username, err := service.getUserLoggingIn(request)
  	if err != nil {
  		http.Error(w, http.StatusText(http.StatusInternalServerError), http.StatusInternalServerError)
  		return
  	}
  	if username == "" {
  		sessions.Save(request, w)
  		http.Error(w, http.StatusText(http.StatusUnauthorized), http.StatusUnauthorized)
  		return
  	}
  	values := struct {
  		Totpcode string `json:"totpcode"`
  	}{}
  
  	if err := json.NewDecoder(request.Body).Decode(&values); err != nil {
  		log.Debug("Error decoding the totp confirmation request:", err)
  		http.Error(w, http.StatusText(http.StatusBadRequest), http.StatusBadRequest)
  		return
  	}
  	var validtotpcode bool
  	totpMgr := totp.NewManager(request)
  	if validtotpcode, err = totpMgr.Validate(username, values.Totpcode); err != nil {
  		http.Error(w, http.StatusText(http.StatusInternalServerError), http.StatusInternalServerError)
  		return
  	}
  	if !validtotpcode { //TODO: limit to 3 failed attempts
  		w.WriteHeader(422)
  		return
  	}
  
  	//add last 2fa date if logging in with oauth2
  	service.storeLast2FALogin(request, username)
  
  	service.loginUser(w, request, username)
  }
docs: //ProcessTOTPConfirmation checks the totp 2 factor authentication code