From 3418dd11278adb106e2080b29309ee37f142f94b Mon Sep 17 00:00:00 2001 From: Johannes Batzill Date: Tue, 31 Oct 2023 04:25:12 +0000 Subject: [PATCH] [Protection Rules] Load user from store in pre-receive hook (#747) --- app/api/controller/githook/pre_receive.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/app/api/controller/githook/pre_receive.go b/app/api/controller/githook/pre_receive.go index e3c93a62a..d6b248b0d 100644 --- a/app/api/controller/githook/pre_receive.go +++ b/app/api/controller/githook/pre_receive.go @@ -67,9 +67,14 @@ func (c *Controller) PreReceive( return output, nil } - // TODO: Remove the dummy session and use the real session, once that has been done and the session has a value. + // TODO: use store.PrincipalInfoCache once we abstracted principals. + principal, err := c.principalStore.Find(ctx, principalID) + if err != nil { + return nil, fmt.Errorf("failed to find inner principal with id %d: %w", principalID, err) + } + dummySession := &auth.Session{ - Principal: types.Principal{ID: principalID, Admin: false}, // TODO: In the dummySession "Admin" is always false + Principal: *principal, Metadata: nil, }