diff --git a/lib/kmxgit/user_manager/user.ex b/lib/kmxgit/user_manager/user.ex
index 7cfd687..231cc71 100644
--- a/lib/kmxgit/user_manager/user.ex
+++ b/lib/kmxgit/user_manager/user.ex
@@ -26,7 +26,8 @@ defmodule Kmxgit.UserManager.User do
|> validate_required([:email, :login, :encrypted_password])
|> validate_format(:email, ~r/^[-_.0-9A-Za-z]+@([-_0-9A-Za-z]+[.])+[A-Za-z]+$/)
|> validate_format(:login, ~r/^[A-Za-z][-_0-9A-Za-z]{1,64}$/)
- |> unique_constraint(:login)
+ |> unique_constraint(:_lower_email)
+ |> unique_constraint(:_lower_login)
|> Markdown.validate_markdown(:description)
end
diff --git a/lib/kmxgit_web/controllers/admin/dashboard_controller.ex b/lib/kmxgit_web/controllers/admin/dashboard_controller.ex
index 7432010..ee54c50 100644
--- a/lib/kmxgit_web/controllers/admin/dashboard_controller.ex
+++ b/lib/kmxgit_web/controllers/admin/dashboard_controller.ex
@@ -3,6 +3,7 @@ defmodule KmxgitWeb.Admin.DashboardController do
def index(conn, _params) do
conn
+ |> assign(:page_title, gettext "Dashboard")
|> render("index.html")
end
end
diff --git a/lib/kmxgit_web/controllers/admin/user_controller.ex b/lib/kmxgit_web/controllers/admin/user_controller.ex
index e8ed995..614aef9 100644
--- a/lib/kmxgit_web/controllers/admin/user_controller.ex
+++ b/lib/kmxgit_web/controllers/admin/user_controller.ex
@@ -7,6 +7,7 @@ defmodule KmxgitWeb.Admin.UserController do
def index(conn, _params) do
users = UserManager.list_users
conn
+ |> assign(:page_title, gettext("Users"))
|> assign(:users, users)
|> render("index.html")
end
@@ -29,6 +30,7 @@ defmodule KmxgitWeb.Admin.UserController do
defp show_user(conn, user) do
conn
+ |> assign(:page_title, gettext("User %{login}", login: user.login))
|> assign(:user, user)
|> render("show.html")
end
diff --git a/lib/kmxgit_web/controllers/session_controller.ex b/lib/kmxgit_web/controllers/session_controller.ex
index a66df24..f5178ed 100644
--- a/lib/kmxgit_web/controllers/session_controller.ex
+++ b/lib/kmxgit_web/controllers/session_controller.ex
@@ -15,7 +15,11 @@ defmodule KmxgitWeb.SessionController do
else
Routes.session_path(conn, :login)
end
- render(conn, "new.html", changeset: changeset, action: action)
+ conn
+ |> assign(:action, action)
+ |> assign(:changeset, changeset)
+ |> assign(:page_title, gettext "Login")
+ |> render("new.html")
end
end
diff --git a/lib/kmxgit_web/controllers/user_controller.ex b/lib/kmxgit_web/controllers/user_controller.ex
index 1989f45..2e9844c 100644
--- a/lib/kmxgit_web/controllers/user_controller.ex
+++ b/lib/kmxgit_web/controllers/user_controller.ex
@@ -14,6 +14,7 @@ defmodule KmxgitWeb.UserController do
end
if user do
conn
+ |> assign(:page_title, gettext("User %{login}", login: user.login))
|> render("show.html", user: user)
else
conn
@@ -33,6 +34,7 @@ defmodule KmxgitWeb.UserController do
if params["login"] == current_user.login do
changeset = User.changeset(current_user)
conn
+ |> assign(:page_title, gettext("Edit user %{login}", login: current_user.login))
|> render("edit.html", changeset: changeset)
else
not_found(conn)
diff --git a/lib/kmxgit_web/router.ex b/lib/kmxgit_web/router.ex
index da404a6..a1526f8 100644
--- a/lib/kmxgit_web/router.ex
+++ b/lib/kmxgit_web/router.ex
@@ -65,8 +65,8 @@ defmodule KmxgitWeb.Router do
scope "/admin", Admin, as: "admin" do
pipe_through :admin
get "/", DashboardController, :index
- resources "/org", OrganisationController
- resources "/u", UserController
+ resources "/organisations", OrganisationController
+ resources "/users", UserController
import Phoenix.LiveDashboard.Router
live_dashboard "/dashboard", metrics: KmxgitWeb.Telemetry
diff --git a/lib/kmxgit_web/templates/admin/user/index.html.heex b/lib/kmxgit_web/templates/admin/user/index.html.heex
index 78dbf47..0499b9b 100644
--- a/lib/kmxgit_web/templates/admin/user/index.html.heex
+++ b/lib/kmxgit_web/templates/admin/user/index.html.heex
@@ -13,7 +13,7 @@
<td><%= link user.id, to: Routes.admin_user_path(@conn, :show, user) %></td>
<td><%= user.name %></td>
<td><%= link user.email, to: "mailto:#{user.email}" %></td>
- <td><%= link user.login, to: Routes.admin_user_path(@conn, :show, user) %></td>
+ <td><%= link user.login, to: Routes.user_path(@conn, :show, user.login) %></td>
<td><%= user.is_admin %></td>
</tr>
<% end %>
diff --git a/lib/kmxgit_web/templates/admin/user/show.html.heex b/lib/kmxgit_web/templates/admin/user/show.html.heex
index 03d35a5..fcf9f6f 100644
--- a/lib/kmxgit_web/templates/admin/user/show.html.heex
+++ b/lib/kmxgit_web/templates/admin/user/show.html.heex
@@ -15,7 +15,7 @@
</tr>
<tr>
<th><%= gettext "Login" %></th>
- <td><%= @user.login %></td>
+ <td><%= link @user.login, to: Routes.user_path(@conn, :show, @user.login) %></td>
</tr>
<tr>
<th><%= gettext "Admin" %></th>
diff --git a/lib/kmxgit_web/templates/layout/admin.html.heex b/lib/kmxgit_web/templates/layout/admin.html.heex
index 77be6a0..8588192 100644
--- a/lib/kmxgit_web/templates/layout/admin.html.heex
+++ b/lib/kmxgit_web/templates/layout/admin.html.heex
@@ -5,7 +5,11 @@
<meta http-equiv="X-UA-Compatible" content="IE=edge"/>
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
<%= csrf_meta_tag() %>
- <%= live_title_tag assigns[:page_title] || "", suffix: " · kmx git admin" %>
+ <%= if assigns[:page_title] do %>
+ <%= live_title_tag assigns[:page_title], suffix: " · kmx git [admin]" %>
+ <% else %>
+ <%= live_title_tag "kmx git [admin]" %>
+ <% end %>
<link phx-track-static rel="stylesheet" href={Routes.static_path(@conn, "/assets/app.css")}/>
<script defer phx-track-static type="text/javascript" src={Routes.static_path(@conn, "/assets/app.js")}></script>
</head>
diff --git a/lib/kmxgit_web/templates/layout/nav_connected.html.heex b/lib/kmxgit_web/templates/layout/nav_connected.html.heex
index 0e9791d..8e1f0a2 100644
--- a/lib/kmxgit_web/templates/layout/nav_connected.html.heex
+++ b/lib/kmxgit_web/templates/layout/nav_connected.html.heex
@@ -6,7 +6,7 @@
</li>
<% end %>
<li class="nav-item">
- <%= link User.display_name(@current_user), to: Routes.user_path(@conn, :show, @current_user.login), class: "nav-link" %>
+ <%= link @current_user.login, to: Routes.user_path(@conn, :show, @current_user.login), class: "nav-link" %>
</li>
<%= if @current_user.is_admin do %>
<li class="nav-item">
diff --git a/lib/kmxgit_web/templates/layout/root.html.heex b/lib/kmxgit_web/templates/layout/root.html.heex
index 5991ad3..9a94640 100644
--- a/lib/kmxgit_web/templates/layout/root.html.heex
+++ b/lib/kmxgit_web/templates/layout/root.html.heex
@@ -5,7 +5,11 @@
<meta http-equiv="X-UA-Compatible" content="IE=edge"/>
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
<%= csrf_meta_tag() %>
- <%= live_title_tag assigns[:page_title] || "", suffix: " · kmx git" %>
+ <%= if assigns[:page_title] do %>
+ <%= live_title_tag assigns[:page_title], suffix: " · kmx git" %>
+ <% else %>
+ <%= live_title_tag "kmx git" %>
+ <% end %>
<link phx-track-static rel="stylesheet" href={Routes.static_path(@conn, "/assets/app.css")}/>
<script defer phx-track-static type="text/javascript" src={Routes.static_path(@conn, "/assets/app.js")}></script>
</head>
diff --git a/lib/kmxgit_web/templates/registration/new.html.heex b/lib/kmxgit_web/templates/registration/new.html.heex
new file mode 100644
index 0000000..df1a754
--- /dev/null
+++ b/lib/kmxgit_web/templates/registration/new.html.heex
@@ -0,0 +1,41 @@
+<div class="container-fluid">
+ <h1><%= gettext "Register" %></h1>
+
+ <%= form_for @changeset, @action, fn f -> %>
+
+ <div class="mb-3">
+ <%= label f, :name, class: "form-label" %>
+ <%= text_input f, :name, class: "form-control" %>
+ <%= error_tag f, :name %>
+ </div>
+
+ <div class="mb-3">
+ <%= label f, :email, class: "form-label" %>
+ <%= text_input f, :email, class: "form-control" %>
+ <%= error_tag f, :email %>
+ </div>
+
+ <div class="mb-3">
+ <%= label f, :login, class: "form-label" %>
+ <%= text_input f, :login, class: "form-control" %>
+ <%= error_tag f, :login %>
+ </div>
+
+ <div class="mb-3">
+ <%= label f, :password, class: "form-label" %>
+ <%= password_input f, :password, class: "form-control" %>
+ <%= error_tag f, :password %>
+ </div>
+
+ <div class="mb-3">
+ <%= label f, :password_confirmation, class: "form-label" %>
+ <%= password_input f, :password_confirmation, class: "form-control" %>
+ <%= error_tag f, :password_confirmation %>
+ </div>
+
+ <div class="mb-3">
+ <%= submit "Submit", class: "btn btn-primary" %>
+ </div>
+
+ <% end %>
+</div>
diff --git a/lib/kmxgit_web/templates/session/new.html.eex b/lib/kmxgit_web/templates/session/new.html.eex
index a33ca46..ca6d85e 100644
--- a/lib/kmxgit_web/templates/session/new.html.eex
+++ b/lib/kmxgit_web/templates/session/new.html.eex
@@ -5,19 +5,19 @@
</h1>
<%= form_for @changeset, @action, fn f -> %>
- <div class="form-group">
- <%= label f, :login, class: "control-label" %>
+ <div class="mb-3">
+ <%= label f, :login, class: "form-label" %>
<%= text_input f, :login, class: "form-control" %>
<%= error_tag f, :login %>
</div>
- <div class="form-group">
- <%= label f, :password, class: "control-label" %>
+ <div class="mb-3">
+ <%= label f, :password, class: "form-label" %>
<%= password_input f, :password, class: "form-control" %>
<%= error_tag f, :password %>
</div>
- <div class="form-group">
+ <div class="mb-3">
<%= submit "Submit", class: "btn btn-primary" %>
</div>
diff --git a/lib/kmxgit_web/templates/user/edit.html.heex b/lib/kmxgit_web/templates/user/edit.html.heex
new file mode 100644
index 0000000..1a8ec81
--- /dev/null
+++ b/lib/kmxgit_web/templates/user/edit.html.heex
@@ -0,0 +1,50 @@
+<div class="container-fluid center">
+ <h1>Edit user</h1>
+ <%= form_for @changeset, Routes.user_path(@conn, :update, @current_user.login), fn f -> %>
+
+ <div class="mb-3">
+ <%= label f, :name, class: "form-label" %>
+ <%= text_input f, :name, class: "form-control" %>
+ <%= error_tag f, :name %>
+ </div>
+
+ <div class="mb-3">
+ <%= label f, :email, class: "form-label" %>
+ <%= text_input f, :email, class: "form-control" %>
+ <%= error_tag f, :email %>
+ </div>
+
+ <div class="mb-3">
+ <%= label f, :login, class: "form-label" %>
+ <%= text_input f, :login, class: "form-control" %>
+ <%= error_tag f, :login %>
+ </div>
+
+ <div class="mb-3">
+ <%= label f, :password, class: "form-label" %>
+ <%= password_input f, :password, class: "form-control" %>
+ <%= error_tag f, :password %>
+ </div>
+
+ <div class="mb-3">
+ <%= label f, :password_confirmation, class: "form-label" %>
+ <%= password_input f, :password_confirmation, class: "form-control" %>
+ <%= error_tag f, :password_confirmation %>
+ </div>
+
+ <div class="mb-3">
+ <%= label f, :description, class: "form-label" %>
+ <%= textarea f, :description, class: "form-control" %>
+ <%= error_tag f, :description %>
+ </div>
+
+ <div class="mb-3">
+ <%= link gettext("Cancel"),
+ to: Routes.user_path(@conn, :show, @current_user.login),
+ class: "btn btn-secondary" %>
+
+ <%= submit gettext("Submit"), class: "btn btn-primary" %>
+ </div>
+
+ <% end %>
+</div>
diff --git a/lib/kmxgit_web/templates/user/show.html.heex b/lib/kmxgit_web/templates/user/show.html.heex
new file mode 100644
index 0000000..9a58572
--- /dev/null
+++ b/lib/kmxgit_web/templates/user/show.html.heex
@@ -0,0 +1,59 @@
+<div class="container-fluid">
+ <div class="row">
+ <div class="col col-12 col-sm-8">
+ <h1><%= @user.login %></h1>
+ </div>
+ <div class="col col-12 col-sm-4">
+ <%= link gettext("Edit"),
+ to: Routes.user_path(@conn, :edit, @user.login),
+ class: "btn btn-primary" %>
+ </div>
+ </div>
+
+ <div class="row">
+ <div class="col col-12 col-md-8">
+ <hr/>
+ <h2><%= gettext "Repositories" %></h2>
+ </div>
+ <div class="col col-12 col-md-4">
+ <hr/>
+ <h2><%= gettext "Properties" %></h2>
+ <table class="table admin-properties">
+ <tr>
+ <th><%= gettext "Name" %></th>
+ <td><%= @user.name %></td>
+ </tr>
+ <tr>
+ <th><%= gettext "Email" %></th>
+ <td><%= link @user.email, to: "mailto:#{@user.email}" %></td>
+ </tr>
+ <tr>
+ <th><%= gettext "Login" %></th>
+ <td><%= @user.login %></td>
+ </tr>
+ <tr>
+ <th><%= gettext "Description" %></th>
+ <td>
+ <%= if @user.description do %>
+ <%= raw Earmark.as_html!(@user.description) %>
+ <% end %>
+ </td>
+ </tr>
+ <tr>
+ <th><%= gettext "Organisations" %></th>
+ <td>
+
+ </td>
+ </tr>
+ <tr>
+ <th><%= gettext "SSH keys" %></th>
+ <td>
+ </td>
+ </tr>
+ </table>
+ </div>
+ </div>
+ <p>
+ </p>
+
+</div>
diff --git a/lib/kmxgit_web/views/registration_view.ex b/lib/kmxgit_web/views/registration_view.ex
new file mode 100644
index 0000000..c70837e
--- /dev/null
+++ b/lib/kmxgit_web/views/registration_view.ex
@@ -0,0 +1,3 @@
+defmodule KmxgitWeb.RegistrationView do
+ use KmxgitWeb, :view
+end