mirror of
https://github.com/documize/community.git
synced 2025-07-19 13:19:43 +02:00
Record details of failed tenant access
This commit is contained in:
parent
958f4d30b9
commit
b2e3f2be7e
1 changed files with 10 additions and 1 deletions
|
@ -13,8 +13,10 @@ package server
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"database/sql"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"errors"
|
"errors"
|
||||||
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
@ -77,9 +79,10 @@ func (m *middleware) Authorize(w http.ResponseWriter, r *http.Request, next http
|
||||||
|
|
||||||
var org = org.Organization{}
|
var org = org.Organization{}
|
||||||
var err = errors.New("")
|
var err = errors.New("")
|
||||||
|
var dom string
|
||||||
|
|
||||||
if len(rc.OrgID) == 0 {
|
if len(rc.OrgID) == 0 {
|
||||||
dom := organization.GetRequestSubdomain(r)
|
dom = organization.GetRequestSubdomain(r)
|
||||||
dom = m.Store.Organization.CheckDomain(rc, dom)
|
dom = m.Store.Organization.CheckDomain(rc, dom)
|
||||||
org, err = m.Store.Organization.GetOrganizationByDomain(dom)
|
org, err = m.Store.Organization.GetOrganizationByDomain(dom)
|
||||||
} else {
|
} else {
|
||||||
|
@ -88,6 +91,12 @@ func (m *middleware) Authorize(w http.ResponseWriter, r *http.Request, next http
|
||||||
|
|
||||||
// Inability to find org record spells the end of this request.
|
// Inability to find org record spells the end of this request.
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
if err == sql.ErrNoRows {
|
||||||
|
response.WriteForbiddenError(w)
|
||||||
|
m.Runtime.Log.Info(fmt.Sprintf("unable to find org (domain: %s, orgID: %s)", dom, rc.OrgID))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
response.WriteForbiddenError(w)
|
response.WriteForbiddenError(w)
|
||||||
m.Runtime.Log.Error(method, err)
|
m.Runtime.Log.Error(method, err)
|
||||||
return
|
return
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue