Upload of project source code files.

This commit is contained in:
2026-02-17 03:56:54 +01:00
parent 2dded110c8
commit ed6df5efbe
70 changed files with 12395 additions and 0 deletions

View File

@@ -0,0 +1,31 @@
defmodule VishnyaWeb.Plugs.Authenticate do
import Plug.Conn
alias Vishnya.Repo
alias Vishnya.Accounts.User
def init(default), do: default
def call(conn, _default) do
case get_req_header(conn, "authorization") do
["Bearer " <> token] ->
case authenticate_token(token) do
nil ->
conn
|> send_resp(401, "Unauthorized")
|> halt()
user ->
assign(conn, :user, user)
end
_ ->
conn
|> send_resp(401, "Unauthorized")
|> halt()
end
end
defp authenticate_token(token) do
Repo.get_by(User, token: token)
end
end