Fakultas Ilmu Komputer UI

Commit dde06526 authored by Muhammad Rafif Elfazri's avatar Muhammad Rafif Elfazri
Browse files

Remove guardian plug on api/auth

parent 594751f7
......@@ -59,12 +59,20 @@ defmodule DiskuyWeb.UserController do
# end
def callback(conn, _params) do
token = Guardian.Plug.current_token(conn)
token_header = get_req_header(conn, "authorization")
case token_header do
[] ->
{:error, :unauthorized}
[token_bearer]->
["Bearer", token|_] = String.split(token_bearer, " ")
with {:ok, user, new_token}= GoogleAuth.create_local_token(token) do
conn
|> put_status(:created)
|> render("user_token.json", %{user: user, token: new_token})
end
_ ->
{:error, :bad_request}
end
end
end
......@@ -58,7 +58,7 @@ defmodule DiskuyWeb.Router do
end
scope "/api/auth", DiskuyWeb do
pipe_through [:api, :auth_token]
pipe_through :api
get "/google/callback", UserController, :callback
options "/google/callback", UserController, :options
end
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment