Skip to content

Instantly share code, notes, and snippets.

@bnhansn
Last active October 21, 2016 20:38
Show Gist options
  • Save bnhansn/36a6985393cf4b8ca4ca145cdcdf958c to your computer and use it in GitHub Desktop.
Save bnhansn/36a6985393cf4b8ca4ca145cdcdf958c to your computer and use it in GitHub Desktop.
# top of file...
plug Guardian.Plug.EnsureAuthenticated, [handler: Sling.SessionController] when action in [:rooms]
# bottom of file...
def rooms(conn, _params) do
current_user = Guardian.Plug.current_resource(conn)
rooms = Repo.all(assoc(current_user, :rooms))
render(conn, Sling.RoomView, "index.json", %{rooms: rooms})
end
# ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment