Compare commits

..

1 Commits

Author SHA1 Message Date
bluepython508
c5f28a9c15 Nixos module 2023-11-10 00:16:54 +00:00
2 changed files with 7 additions and 12 deletions

View File

@@ -24,17 +24,12 @@ defmodule SsoBsnWeb.UserSessionController do
end
def check_auth(conn, _params) do
if user = conn.assigns[:current_user] do
user = conn.assigns[:current_user]
conn
|> put_resp_header("X-Auth-Username", user.username)
|> json(%{
username: user.username
})
else
conn
|> put_status(:unauthorized)
|> text("Unauthorized")
end
end
def redirect_next(conn, %{ "next" => next }) do

View File

@@ -75,7 +75,7 @@ defmodule SsoBsnWeb.Router do
end
scope "/", SsoBsnWeb do
pipe_through [:api, :fetch_session, :fetch_current_user]
pipe_through [:api, :fetch_session, :fetch_current_user, :require_authenticated_user]
get "/whoami", UserSessionController, :check_auth
end