-
Notifications
You must be signed in to change notification settings - Fork 246
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Only install in prod and dev - Upgrade to 2.10 (RC for now) - Use new resolver 'forbidden' feature - Remove no-longer-needed plugins - Only load ObanWeb code when installed
- Loading branch information
1 parent
76cae6b
commit af98b6d
Showing
6 changed files
with
62 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
defmodule ChangelogWeb.ObanWeb do | ||
@moduledoc """ | ||
Simple macro to conditionally load Oban.Web only if already loaded. This | ||
allows us to include it only in the production release and hence make it a lot | ||
easier on potential open source contributors, avoiding the problem of sharing | ||
the oban key and/or them hacking the code to get it working | ||
Thanks to the team at Glific for showing us the way on this. | ||
""" | ||
|
||
defmacro __using__(_) do | ||
if Code.ensure_loaded?(Oban.Web.Router) do | ||
defmodule Resolver do | ||
@behaviour Oban.Web.Resolver | ||
|
||
@impl true | ||
def resolve_user(conn) do | ||
conn.assigns.current_user | ||
end | ||
|
||
@impl true | ||
def resolve_access(user) do | ||
if Changelog.Policies.AdminsOnly.index(user) do | ||
:all | ||
else | ||
{:forbidden, "/in"} | ||
end | ||
end | ||
end | ||
|
||
quote do | ||
import Oban.Web.Router | ||
|
||
scope "/admin" do | ||
pipe_through [:browser, :admin] | ||
|
||
oban_dashboard("/oban", resolver: ChangelogWeb.ObanWeb.Resolver) | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.