-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Back office events #24
Conversation
Pull Request Test Coverage Report for Build 252
💛 - Coveralls |
pkg/management/component.go
Outdated
|
||
if err != nil { | ||
return "", err | ||
} | ||
|
||
//store the API call into the DB | ||
var event = make(map[string]string) | ||
event["ct_event_type"] = "API_ACCOUNT_CREATION" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In component.go, we don't want to many business unrelated code in our functions. We should try to have the less "invasive" code as possible here. Could we create functions like :
var event map[string]string = events.CreateEventMap("API_ACCOUNT_CREATION")
events.AddEventValues("realm_name", realmName, "user_id", user.Id, "username", user.Username, "origin", "back-office", "audit-time", time.Now().UTC())
and somewhere else :
func CreateEventMap(apiName string /* and other generic parameters... */) map[string]string {
event["ct_event_type"] = apiName
event["origin"] = "back-office"
event["audit_time"] = time.Now().UTC().Format("2006-01-02 15:04:05.000")
}
func AddEventValues(eventNfo map[string]string, values string...) {
// can automatically ignore key/value when value is nil
}
func AddEventTime(eventNfo map[string]string, fieldName string, time time.Time) {
}
To illustrate what is worrying me, the initial DeleteUser function is only 2 lines long to do what it is aimed to but is more than 20 lines with code not related to user deletion.
…ridge into back_office_events
Store in the DB the following events:
API_ACCOUNT_CREATION
API_ACCOUNT_DELETION
GET_DETAILS
LOCK_ACCOUNT
UNLOCK_ACCOUNT
INIT_PASSWORD
& restructuring the event module and component