mirror of
https://github.com/philomena-dev/philomena.git
synced 2024-11-24 12:37:58 +01:00
33 lines
No EOL
846 B
Elixir
33 lines
No EOL
846 B
Elixir
defmodule PhilomenaWeb.FingerprintProfileController do
|
|
use PhilomenaWeb, :controller
|
|
|
|
alias Philomena.UserFingerprints.UserFingerprint
|
|
alias Philomena.Bans.Fingerprint
|
|
alias Philomena.Repo
|
|
import Ecto.Query
|
|
|
|
plug :authorize_ip
|
|
|
|
def show(conn, %{"id" => fingerprint}) do
|
|
user_fps =
|
|
UserFingerprint
|
|
|> where(fingerprint: ^fingerprint)
|
|
|> order_by(desc: :updated_at)
|
|
|> preload(:user)
|
|
|> Repo.all()
|
|
|
|
fp_bans =
|
|
Fingerprint
|
|
|> where(fingerprint: ^fingerprint)
|
|
|> Repo.all()
|
|
|
|
render(conn, "show.html", fingerprint: fingerprint, user_fps: user_fps, fp_bans: fp_bans)
|
|
end
|
|
|
|
defp authorize_ip(conn, _opts) do
|
|
case Canada.Can.can?(conn.assigns.current_user, :show, :ip_address) do
|
|
false -> PhilomenaWeb.NotAuthorizedPlug.call(conn)
|
|
true -> conn
|
|
end
|
|
end
|
|
end |