Fakultas Ilmu Komputer UI

Commit 6f93adf5 authored by Muhammad Rafif Elfazri's avatar Muhammad Rafif Elfazri
Browse files

Add update userinfo function

parent 2086d4d2
......@@ -34,9 +34,9 @@ defmodule DiskuyWeb.UserController do
def update(conn, %{"id" => id, "user" => user_params}) do
user = Account.get_user!(id)
new_user_params = Map.drop(user_params, ["email"])
def update(conn, %{"user" => user_params}) do
user = Guardian.Plug.current_resource(conn)
new_user_params = user_params |> Map.drop(["email", "id"])
with {:ok, %User{} = user} <- Account.update_user(user, new_user_params) do
render(conn, "show.json", user: user)
......@@ -20,6 +20,8 @@ defmodule DiskuyWeb.Router do
resources "/threads", ThreadController, except: [:new, :edit, :show, :index]
resources "/topics", TopicController, except: [:new, :edit, :show, :index]
resources "/post", PostController, except: [:new, :edit, :show, :index]
put "/users/update", UserController, :update
post "/threads/like/:id", ThreadController, :add_like
options "/threads/like/:id", ThreadController, :options
post "/threads/dislike/:id", ThreadController, :delete_like
Markdown is supported
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