submissions: check role for map location #213

Merged
Quaternions merged 1 commits from pr2 into staging 2025-06-30 09:46:50 +00:00

View File

@@ -80,6 +80,20 @@ func (svc *Service) GetMap(ctx context.Context, params api.GetMapParams) (*api.M
//
// GET /maps/{MapID}/location
func (svc *Service) GetMapAssetLocation(ctx context.Context, params api.GetMapAssetLocationParams) (ok api.GetMapAssetLocationOK, err error) {
userInfo, success := ctx.Value("UserInfo").(UserInfoHandle)
if !success {
return ok, ErrUserInfo
}
has_role, err := userInfo.HasRoleMapDownload()
if err != nil {
return ok, err
}
if !has_role {
return ok, ErrPermissionDeniedNeedRoleMapDownload
}
// Ensure map exists in the db!
// This could otherwise be used to access any asset
_, err = svc.Maps.Get(ctx, &maps.IdMessage{