mirror of
https://github.com/netbirdio/netbird.git
synced 2026-05-06 17:08:53 +00:00
Add join user operation
This commit is contained in:
@@ -752,6 +752,20 @@ func (am *DefaultAccountManager) handleNewUserAccount(domainAcc *Account, claims
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
opEvent := event.Event{
|
||||||
|
Timestamp: time.Now(),
|
||||||
|
Type: event.ManagementEvent,
|
||||||
|
OperationCode: event.UserJoinedOperation,
|
||||||
|
AccountID: account.Id,
|
||||||
|
TargetID: claims.UserId,
|
||||||
|
ModifierID: claims.UserId,
|
||||||
|
}
|
||||||
|
|
||||||
|
_, err = am.eventStore.Save(opEvent)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
return account, nil
|
return account, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -12,13 +12,29 @@ const (
|
|||||||
const (
|
const (
|
||||||
AddPeerByUserOperation Operation = iota
|
AddPeerByUserOperation Operation = iota
|
||||||
AddPeerWithKeyOperation
|
AddPeerWithKeyOperation
|
||||||
|
UserJoinedOperation
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
AddPeerByUserOperationMessage string = "Add new peer"
|
AddPeerByUserOperationMessage string = "Add new peer"
|
||||||
AddPeerWithKeyOperationMessage string = AddPeerByUserOperationMessage
|
AddPeerWithKeyOperationMessage string = AddPeerByUserOperationMessage
|
||||||
|
UserJoinedOperationMessage string = "New user joined"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// MessageForOperation returns a string message for an Operation
|
||||||
|
func MessageForOperation(op Operation) string {
|
||||||
|
switch op {
|
||||||
|
case AddPeerByUserOperation:
|
||||||
|
return AddPeerByUserOperationMessage
|
||||||
|
case AddPeerWithKeyOperation:
|
||||||
|
return AddPeerWithKeyOperationMessage
|
||||||
|
case UserJoinedOperation:
|
||||||
|
return UserJoinedOperationMessage
|
||||||
|
default:
|
||||||
|
return "UNKNOWN_OPERATION"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Type of the Event
|
// Type of the Event
|
||||||
type Type string
|
type Type string
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user