login screen and related auth logic implemented #1
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
@ -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
|
@ -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
|
@ -1,17 +0,0 @@
|
||||
<header>
|
||||
DrainCloud
|
||||
</header>
|
||||
<div class="login-container">
|
||||
<h2>Login</h2>
|
||||
<form action="/login" method="post">
|
||||
<div class="input-group">
|
||||
<label for="username">Username</label>
|
||||
<input type="text" id="username" name="username" required>
|
||||
</div>
|
||||
<div class="input-group">
|
||||
<label for="password">Password</label>
|
||||
<input type="password" id="password" name="password" required>
|
||||
</div>
|
||||
<button type="submit" class="login-button">Login</button>
|
||||
</form>
|
||||
</div>
|
@ -1,17 +0,0 @@
|
||||
<header>
|
||||
DrainCloud
|
||||
</header>
|
||||
<div class="login-container">
|
||||
<h2>Login</h2>
|
||||
<form action="/login" method="post">
|
||||
<div class="input-group">
|
||||
<label for="username">Username</label>
|
||||
<input type="text" id="username" name="username" required>
|
||||
</div>
|
||||
<div class="input-group">
|
||||
<label for="password">Password</label>
|
||||
<input type="password" id="password" name="password" required>
|
||||
</div>
|
||||
<button type="submit" class="login-button">Login</button>
|
||||
</form>
|
||||
</div>
|
@ -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.
|
||||
|
Loading…
Reference in New Issue
Block a user