Fakultas Ilmu Komputer UI

Commit 8ae334dc authored by Muhammad Rafif Elfazri's avatar Muhammad Rafif Elfazri
Browse files

Comment on previous auth jwt system

parent fd46e18b
......@@ -13,15 +13,15 @@ defmodule DiskuyWeb.UserController do
render(conn, "index.json", users: users)
end
def create(conn, %{"user" => user_params}) do
with {:ok, %User{} = user} <- Account.create_user(user_params),
{:ok, token, _claims} <- Guardian.encode_and_sign(user) do
conn
|> put_status(:created)
|> put_resp_header("location", Routes.user_path(conn, :show, user))
|> render("user_token.json", %{user: user, token: token})
end
end
# def create(conn, %{"user" => user_params}) do
# with {:ok, %User{} = user} <- Account.create_user(user_params),
# {:ok, token, _claims} <- Guardian.encode_and_sign(user) do
# conn
# |> put_status(:created)
# |> put_resp_header("location", Routes.user_path(conn, :show, user))
# |> render("user_token.json", %{user: user, token: token})
# end
# end
def show(conn, %{"id" => id}) do
user = Account.get_user!(id)
......@@ -50,13 +50,13 @@ defmodule DiskuyWeb.UserController do
end
end
def signin(conn, %{"email" => email, "password" => password}) do
with {:ok, user, token} <- Guardian.authenticate(email, password) do
conn
|> put_status(:created)
|> render("user_token.json", %{user: user, token: token})
end
end
# def signin(conn, %{"email" => email, "password" => password}) do
# with {:ok, user, token} <- Guardian.authenticate(email, password) do
# conn
# |> put_status(:created)
# |> render("user_token.json", %{user: user, token: token})
# end
# end
def callback(conn, %{"code" => code}) do
with {:ok, token} = GoogleAuth.get_access_token(code, conn),
......
......@@ -45,10 +45,12 @@ defmodule DiskuyWeb.Router do
resources "/post", PostController, except: [:new, :edit, :create, :update, :delete]
options "/post", PostController, :options
options "/post/:id", PostController, :options
post "/users/signup", UserController, :create
options "/users/signup", PostController, :options
post "/users/signin", UserController, :signin
options "/users/signin", PostController, :options
# post "/users/signup", UserController, :create
# options "/users/signup", PostController, :options
# post "/users/signin", UserController, :signin
# options "/users/signin", PostController, :options
end
scope "/auth/google", DiskuyWeb do
......
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