Decode bearer token

This commit is contained in:
Ivan R. 2024-10-17 14:38:02 +05:00
parent 385997701f
commit c28ef2466c
Signed by: lumin
GPG key ID: E0937DC7CD6D3817

View file

@ -116,8 +116,9 @@ defmodule ComfycampWeb.UserAuth do
"""
def fetch_bearer_token(conn, _opts) do
case Plug.Conn.get_req_header(conn, "authorization") do
["Bearer " <> header] ->
user = Accounts.get_user_by_bearer_token(header)
["Bearer " <> b64token] ->
token = Base.decode64(b64token)
user = Accounts.get_user_by_bearer_token(token)
assign(conn, :oauth_user, user)
_ ->