mirror of
https://github.com/empayre/fleet.git
synced 2024-11-06 17:05:18 +00:00
add WriteActions context
This commit is contained in:
parent
a07e9c7d77
commit
d611dc7786
@ -30,7 +30,6 @@ func login(ds kolide.UserStore, logger kitlog.Logger) http.HandlerFunc {
|
||||
logger.Log("err", err, "user", username)
|
||||
return
|
||||
}
|
||||
|
||||
// create session here
|
||||
|
||||
encodeResponse(ctx, w, getUserResponse{
|
||||
@ -158,6 +157,12 @@ func (vc *viewerContext) CanPerformReadActionOnUser(u *kolide.User) bool {
|
||||
return vc.CanPerformActions() || (vc.IsLoggedIn() && vc.IsUserID(u.ID))
|
||||
}
|
||||
|
||||
// CanPerformWriteActionOnUser returns a bool indicating the current user's
|
||||
// ability to perform write actions on the given user
|
||||
func (vc *viewerContext) CanPerformWriteActionOnUser(u *kolide.User) bool {
|
||||
return vc.CanPerformActions() && (vc.IsUserID(u.ID) || vc.IsAdmin())
|
||||
}
|
||||
|
||||
// IsUserID returns true if the given user id the same as the user which is
|
||||
// represented by this ViewerContext
|
||||
func (vc *viewerContext) IsUserID(id uint) bool {
|
||||
|
Loading…
Reference in New Issue
Block a user