mirror of
https://github.com/casdoor/casdoor.git
synced 2025-05-23 02:35:49 +08:00
Add object to webhook
This commit is contained in:
parent
54e2055ffb
commit
cc528c5d8c
@ -47,7 +47,8 @@ type Record struct {
|
||||
RequestUri string `xorm:"varchar(1000)" json:"requestUri"`
|
||||
Action string `xorm:"varchar(1000)" json:"action"`
|
||||
|
||||
ExtendedUser *User `xorm:"-" json:"extendedUser"`
|
||||
Object string `xorm:"-" json:"object"`
|
||||
ExtendedUser *User `xorm:"-" json:"extendedUser"`
|
||||
|
||||
IsTriggered bool `json:"isTriggered"`
|
||||
}
|
||||
@ -60,6 +61,11 @@ func NewRecord(ctx *context.Context) *Record {
|
||||
requestUri = requestUri[0:1000]
|
||||
}
|
||||
|
||||
object := ""
|
||||
if ctx.Input.RequestBody != nil && len(ctx.Input.RequestBody) != 0 {
|
||||
object = string(ctx.Input.RequestBody)
|
||||
}
|
||||
|
||||
record := Record{
|
||||
Name: util.GenerateId(),
|
||||
CreatedTime: util.GetCurrentTime(),
|
||||
@ -68,6 +74,7 @@ func NewRecord(ctx *context.Context) *Record {
|
||||
Method: ctx.Request.Method,
|
||||
RequestUri: requestUri,
|
||||
Action: action,
|
||||
Object: object,
|
||||
IsTriggered: false,
|
||||
}
|
||||
return &record
|
||||
@ -159,7 +166,7 @@ func SendWebhooks(record *Record) error {
|
||||
|
||||
if matched {
|
||||
if webhook.IsUserExtended {
|
||||
user := getUser(record.Organization, record.User)
|
||||
user := GetMaskedUser(getUser(record.Organization, record.User))
|
||||
record.ExtendedUser = user
|
||||
}
|
||||
|
||||
|
@ -28,6 +28,20 @@ require("codemirror/mode/javascript/javascript");
|
||||
|
||||
const {Option} = Select;
|
||||
|
||||
const applicationTemplate = {
|
||||
owner: "admin", // this.props.account.applicationName,
|
||||
name: "application_123",
|
||||
organization: "built-in",
|
||||
createdTime: "2022-01-01T01:03:42+08:00",
|
||||
displayName: "New Application - 123",
|
||||
logo: `${Setting.StaticBaseUrl}/img/casdoor-logo_1185x256.png`,
|
||||
enablePassword: true,
|
||||
enableSignUp: true,
|
||||
enableSigninSession: false,
|
||||
enableCodeSignin: false,
|
||||
enableSamlCompress: false,
|
||||
};
|
||||
|
||||
const previewTemplate = {
|
||||
"id": 9078,
|
||||
"owner": "built-in",
|
||||
@ -37,9 +51,10 @@ const previewTemplate = {
|
||||
"clientIp": "159.89.126.192",
|
||||
"user": "admin",
|
||||
"method": "POST",
|
||||
"requestUri": "/api/login",
|
||||
"requestUri": "/api/add-application",
|
||||
"action": "login",
|
||||
"isTriggered": false,
|
||||
"object": JSON.stringify(applicationTemplate),
|
||||
};
|
||||
|
||||
const userTemplate = {
|
||||
@ -49,7 +64,7 @@ const userTemplate = {
|
||||
"updatedTime": "",
|
||||
"id": "9eb20f79-3bb5-4e74-99ac-39e3b9a171e8",
|
||||
"type": "normal-user",
|
||||
"password": "123",
|
||||
"password": "***",
|
||||
"passwordSalt": "",
|
||||
"displayName": "Admin",
|
||||
"avatar": "https://cdn.casbin.com/usercontent/admin/avatar/1596241359.png",
|
||||
|
Loading…
x
Reference in New Issue
Block a user