Add logPostOnly.

This commit is contained in:
Gucheng Wang
2021-11-09 23:32:53 +08:00
parent 102e22f2c7
commit 21f433d278
2 changed files with 18 additions and 0 deletions

View File

@ -12,4 +12,5 @@ authState = "casdoor"
httpProxy = "127.0.0.1:10808" httpProxy = "127.0.0.1:10808"
verificationCodeTimeout = 10 verificationCodeTimeout = 10
initScore = 2000 initScore = 2000
logPostOnly = true
oidcOrigin = "https://door.casbin.com" oidcOrigin = "https://door.casbin.com"

View File

@ -17,10 +17,21 @@ package object
import ( import (
"strings" "strings"
"github.com/astaxie/beego"
"github.com/astaxie/beego/context" "github.com/astaxie/beego/context"
"github.com/casbin/casdoor/util" "github.com/casbin/casdoor/util"
) )
var logPostOnly bool
func init() {
var err error
logPostOnly, err = beego.AppConfig.Bool("logPostOnly")
if err != nil {
panic(err)
}
}
type Record struct { type Record struct {
Id int `xorm:"int notnull pk autoincr" json:"id"` Id int `xorm:"int notnull pk autoincr" json:"id"`
@ -56,6 +67,12 @@ func NewRecord(ctx *context.Context) *Record {
} }
func AddRecord(record *Record) bool { func AddRecord(record *Record) bool {
if logPostOnly {
if record.Method == "GET" {
return false
}
}
record.Owner = record.Organization record.Owner = record.Organization
errWebhook := SendWebhooks(record) errWebhook := SendWebhooks(record)