diff --git a/README.md b/README.md index 50cf6f8..0b50ae0 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,11 @@ # DrainCloudCore +**DrainCloud** is an opensource cloud file management service, aimed for an ease of usage in a self-hosted usage scenarios. +The main goal is to create a *easy-to-host* and very performant application with small footprint. -To start your Phoenix server: +*TODO put docs here* + +## Development +To start your DrainCloudCore server: * Run `mix setup` to install and setup dependencies * Start Phoenix endpoint with `mix phx.server` or inside IEx with `iex -S mix phx.server` @@ -9,7 +14,7 @@ Now you can visit [`localhost:4000`](http://localhost:4000) from your browser. Ready to run in production? Please [check our deployment guides](https://hexdocs.pm/phoenix/deployment.html). -## Learn more +### Some phoenix related links * Official website: https://www.phoenixframework.org/ * Guides: https://hexdocs.pm/phoenix/overview.html diff --git a/lib/draincloud_core_web/controllers/auth_controller/auth_controller.ex b/lib/draincloud_core_web/controllers/auth_controller/auth_controller.ex index d040128..e8e681b 100644 --- a/lib/draincloud_core_web/controllers/auth_controller/auth_controller.ex +++ b/lib/draincloud_core_web/controllers/auth_controller/auth_controller.ex @@ -3,6 +3,10 @@ defmodule DrainCloudCoreWeb.AuthController do alias DrainCloudCoreWeb.Request, as: Request def logon(conn, _params) do - if + if Request.hs_token?(conn) do + # TODO validate token here + end + + end end diff --git a/lib/draincloud_core_web/controllers/main_controller/main_controller.ex b/lib/draincloud_core_web/controllers/main_controller/main_controller.ex new file mode 100644 index 0000000..7a93c37 --- /dev/null +++ b/lib/draincloud_core_web/controllers/main_controller/main_controller.ex @@ -0,0 +1,11 @@ +defmodule DrainCloudCoreWeb.MainController do + use DrainCloudCoreWeb, :controller + + def test(conn, _params) do + conn + |> put_resp_content_type("application/json") + |> put_root_layout(false) + |> json(%{data: %{name: "Some Name"}}) + end + +end diff --git a/lib/draincloud_core_web/controllers/page_controller/page_controller.ex b/lib/draincloud_core_web/controllers/page_controller/page_controller.ex deleted file mode 100644 index 95589a3..0000000 --- a/lib/draincloud_core_web/controllers/page_controller/page_controller.ex +++ /dev/null @@ -1,26 +0,0 @@ -defmodule DrainCloudCoreWeb.PageController do - use DrainCloudCoreWeb, :controller - - def home(conn, _params) do - # The home page is often custom made, - # so skip the default app layout. - - # TODO - # 1. check is user is logged in - # 2. if is - fetch the main page contents (files, folders etc) - # 2.1 fetch session by token. If NotFOund -> (3) - # 2.2 fetch content by sessions user_id - # 2.3 render page - # If not: - # 3. Redirect to the login page - - # if Map.has_key?(conn.req_headers, 'x-access-token') do - # {_, token} = Map.fetch(conn.req_headers, 'x-access-token') - - # end - - :logger.debug("[#{__MODULE__}] request: ", conn) - - render(conn, :home, layout: false) - end -end diff --git a/lib/draincloud_core_web/controllers/page_controller/page_html.ex b/lib/draincloud_core_web/controllers/page_controller/page_html.ex deleted file mode 100644 index 7d0f998..0000000 --- a/lib/draincloud_core_web/controllers/page_controller/page_html.ex +++ /dev/null @@ -1,10 +0,0 @@ -defmodule DrainCloudCoreWeb.PageHTML do - @moduledoc """ - This module contains pages rendered by PageController. - - See the `page_html` directory for all templates available. - """ - use DrainCloudCoreWeb, :html - - embed_templates "page_html/*" -end diff --git a/lib/draincloud_core_web/controllers/page_controller/page_html/home.html.heex b/lib/draincloud_core_web/controllers/page_controller/page_html/home.html.heex deleted file mode 100644 index 658ec98..0000000 --- a/lib/draincloud_core_web/controllers/page_controller/page_html/home.html.heex +++ /dev/null @@ -1,17 +0,0 @@ -
- DrainCloud -
-
-

Login

-
-
- - -
-
- - -
- -
-
\ No newline at end of file diff --git a/lib/draincloud_core_web/controllers/page_controller/page_html/login.html.heex b/lib/draincloud_core_web/controllers/page_controller/page_html/login.html.heex deleted file mode 100644 index 658ec98..0000000 --- a/lib/draincloud_core_web/controllers/page_controller/page_html/login.html.heex +++ /dev/null @@ -1,17 +0,0 @@ -
- DrainCloud -
-
-

Login

-
-
- - -
-
- - -
- -
-
\ No newline at end of file diff --git a/lib/draincloud_core_web/router.ex b/lib/draincloud_core_web/router.ex index 49cf169..9ed3551 100644 --- a/lib/draincloud_core_web/router.ex +++ b/lib/draincloud_core_web/router.ex @@ -15,9 +15,9 @@ defmodule DrainCloudCoreWeb.Router do end scope "/", DrainCloudCoreWeb do - pipe_through :browser + pipe_through :api - get "/", PageController, :home + get "/api", MainController, :test end # Other scopes may use custom stacks.