Compare commits
2 Commits
c5f28a9c15
...
cf60f1140c
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
cf60f1140c | ||
|
|
21ad6931b7 |
@@ -24,12 +24,17 @@ defmodule SsoBsnWeb.UserSessionController do
|
|||||||
end
|
end
|
||||||
|
|
||||||
def check_auth(conn, _params) do
|
def check_auth(conn, _params) do
|
||||||
user = conn.assigns[:current_user]
|
if user = conn.assigns[:current_user] do
|
||||||
conn
|
conn
|
||||||
|> put_resp_header("X-Auth-Username", user.username)
|
|> put_resp_header("X-Auth-Username", user.username)
|
||||||
|> json(%{
|
|> json(%{
|
||||||
username: user.username
|
username: user.username
|
||||||
})
|
})
|
||||||
|
else
|
||||||
|
conn
|
||||||
|
|> put_status(:unauthorized)
|
||||||
|
|> text("Unauthorized")
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def redirect_next(conn, %{ "next" => next }) do
|
def redirect_next(conn, %{ "next" => next }) do
|
||||||
|
|||||||
@@ -75,7 +75,7 @@ defmodule SsoBsnWeb.Router do
|
|||||||
end
|
end
|
||||||
|
|
||||||
scope "/", SsoBsnWeb do
|
scope "/", SsoBsnWeb do
|
||||||
pipe_through [:api, :fetch_session, :fetch_current_user, :require_authenticated_user]
|
pipe_through [:api, :fetch_session, :fetch_current_user]
|
||||||
|
|
||||||
get "/whoami", UserSessionController, :check_auth
|
get "/whoami", UserSessionController, :check_auth
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user