Skip to content

Commit

Permalink
Pass user_id param on check usage limits (#2388)
Browse files Browse the repository at this point in the history
  • Loading branch information
jyeshe authored Aug 19, 2024
1 parent 2222a05 commit 185d67a
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ and this project adheres to

### Added

- Pass the user_id param on check usage limits.
[#2387](https://github.com/OpenFn/lightning/issues/2387)

### Changed

### Fixed
Expand Down
3 changes: 2 additions & 1 deletion lib/lightning/extensions/usage_limiting.ex
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ defmodule Lightning.Extensions.UsageLimiting do
@moduledoc false

@type t :: %Context{
project_id: Ecto.UUID.t()
project_id: Ecto.UUID.t(),
user_id: Ecto.UUID.t()
}

defstruct [:project_id, :user_id]
Expand Down
5 changes: 3 additions & 2 deletions lib/lightning_web/live/live_helpers.ex
Original file line number Diff line number Diff line change
Expand Up @@ -172,9 +172,10 @@ defmodule LightningWeb.LiveHelpers do
%{socket | assigns: check_limits(assigns, project_id)}
end

def check_limits(assigns, project_id) do
def check_limits(%{current_user: user} = assigns, project_id) do
case UsageLimiter.check_limits(%Context{
project_id: project_id
project_id: project_id,
user_id: user.id
}) do
:ok ->
assigns
Expand Down

0 comments on commit 185d67a

Please sign in to comment.