mirror of
https://github.com/TheRealOwenRees/chess-endgame-trainer.git
synced 2026-11-18 11:42:07 +00:00
Compare commits
2
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
fd6277ef92
|
||
|
|
1012c74d60
|
+36
@@ -0,0 +1,36 @@
|
|||||||
|
# Project Roadmap
|
||||||
|
|
||||||
|
High-level implementation milestones and strategic direction
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Phase 1: MVP & Core Functionality (Current Focus)
|
||||||
|
Target: Q1 2027
|
||||||
|
|
||||||
|
- [ ] **Initial UI / Interface**
|
||||||
|
- [ ] Create front page and settle on colour scheme
|
||||||
|
- [ ] Apply colour scheme across the site
|
||||||
|
- [ ] Allow colour theme to be changed on chessboard
|
||||||
|
- [ ] **Core Features**
|
||||||
|
- [x] Log in
|
||||||
|
- [x] Rating of user and puzzles
|
||||||
|
- [x] Implement core API endpoints with input validation.
|
||||||
|
- [ ] Traverse puzzles in easy/medium/hard mode with session timer/rating+/-
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Phase 2: Polish & Reliability
|
||||||
|
Target: Q2 2027
|
||||||
|
|
||||||
|
- [ ] **Security & Compliance**
|
||||||
|
- [ ] Complete security hardening and dependency vulnerability auditing.
|
||||||
|
- [ ] **Testing & Quality Control**
|
||||||
|
- [ ] Expand integration test suite for critical API paths.
|
||||||
|
- [ ] Set up automated WCAG accessibility audits in CI.
|
||||||
|
- [ ] **Performance & Caching**
|
||||||
|
- [ ] Optimize database indexes and payload response sizes.
|
||||||
|
- [x] Implement local caching strategy for high-frequency queries.
|
||||||
|
- [ ] **Logged in user features**
|
||||||
|
- [ ] Allow logged in users to see their progrees on a profile page
|
||||||
|
|
||||||
|
---
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
# Immediate TODOs
|
||||||
|
|
||||||
|
Granular tasks and operational scratchpad for active development.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## In Progress 🟡
|
||||||
|
- [ ] Basic design and colour scheme
|
||||||
|
- [ ] Display puzzles and move to next
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Next Up (Sprint Backlog) 🟢
|
||||||
|
- [ ] Forgot password
|
||||||
|
- [ ] Anonymous trial of 10 puzzles without logging in
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Tech Debt & Refactoring 🧹
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Deferred / Parking Lot 🧊
|
||||||
|
- [ ] Profile page
|
||||||
|
- [ ] Visual guide to user progress / attemps
|
||||||
|
- [ ] Export user data
|
||||||
@@ -212,6 +212,24 @@ defmodule Chesstrainer.Accounts do
|
|||||||
|> update_user_and_delete_all_tokens()
|
|> update_user_and_delete_all_tokens()
|
||||||
end
|
end
|
||||||
|
|
||||||
|
## Deletion
|
||||||
|
|
||||||
|
@doc """
|
||||||
|
Permanently deletes a user and all of their data.
|
||||||
|
|
||||||
|
Attempts and session tokens are removed by database cascades. There is no
|
||||||
|
soft delete and no way to recover the account.
|
||||||
|
|
||||||
|
## Examples
|
||||||
|
|
||||||
|
iex> delete_user(user)
|
||||||
|
{:ok, %User{}}
|
||||||
|
|
||||||
|
"""
|
||||||
|
def delete_user(%User{} = user) do
|
||||||
|
Repo.delete(user)
|
||||||
|
end
|
||||||
|
|
||||||
## Session
|
## Session
|
||||||
|
|
||||||
@doc """
|
@doc """
|
||||||
|
|||||||
@@ -65,6 +65,30 @@ defmodule ChesstrainerWeb.UserLive.Settings do
|
|||||||
Save Password
|
Save Password
|
||||||
</.button>
|
</.button>
|
||||||
</.form>
|
</.form>
|
||||||
|
|
||||||
|
<div class="divider" />
|
||||||
|
|
||||||
|
<section id="delete_account" class="space-y-4">
|
||||||
|
<.header>
|
||||||
|
Delete account
|
||||||
|
<:subtitle>This action is permanent and cannot be undone.</:subtitle>
|
||||||
|
</.header>
|
||||||
|
|
||||||
|
<p class="text-sm text-base-content/70">
|
||||||
|
Deleting your account permanently removes your profile, rating and training history.
|
||||||
|
Nothing can be recovered.
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<button
|
||||||
|
id="delete_account_button"
|
||||||
|
type="button"
|
||||||
|
class="btn btn-error"
|
||||||
|
phx-click="delete_account"
|
||||||
|
data-confirm="This permanently deletes your account and all of your data. Nothing can be recovered. Are you sure?"
|
||||||
|
>
|
||||||
|
Delete my account
|
||||||
|
</button>
|
||||||
|
</section>
|
||||||
</Layouts.app>
|
</Layouts.app>
|
||||||
"""
|
"""
|
||||||
end
|
end
|
||||||
@@ -157,4 +181,16 @@ defmodule ChesstrainerWeb.UserLive.Settings do
|
|||||||
{:noreply, assign(socket, password_form: to_form(changeset, action: :insert))}
|
{:noreply, assign(socket, password_form: to_form(changeset, action: :insert))}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def handle_event("delete_account", _params, socket) do
|
||||||
|
user = socket.assigns.current_scope.user
|
||||||
|
true = Accounts.sudo_mode?(user)
|
||||||
|
|
||||||
|
{:ok, _user} = Accounts.delete_user(user)
|
||||||
|
|
||||||
|
{:noreply,
|
||||||
|
socket
|
||||||
|
|> put_flash(:info, "Your account has been deleted.")
|
||||||
|
|> redirect(to: ~p"/")}
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -4,7 +4,11 @@ defmodule Chesstrainer.AccountsTest do
|
|||||||
alias Chesstrainer.Accounts
|
alias Chesstrainer.Accounts
|
||||||
|
|
||||||
import Chesstrainer.AccountsFixtures
|
import Chesstrainer.AccountsFixtures
|
||||||
|
import Chesstrainer.EndgamesFixtures
|
||||||
alias Chesstrainer.Accounts.{User, UserToken}
|
alias Chesstrainer.Accounts.{User, UserToken}
|
||||||
|
alias Chesstrainer.Attempts
|
||||||
|
alias Chesstrainer.Attempts.Attempt
|
||||||
|
alias Chesstrainer.Accounts.Scope
|
||||||
|
|
||||||
describe "get_user_by_email/1" do
|
describe "get_user_by_email/1" do
|
||||||
test "does not return the user if the email does not exist" do
|
test "does not return the user if the email does not exist" do
|
||||||
@@ -432,6 +436,30 @@ defmodule Chesstrainer.AccountsTest do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe "delete_user/1" do
|
||||||
|
test "deletes the user and their session tokens" do
|
||||||
|
user = user_fixture()
|
||||||
|
token = Accounts.generate_user_session_token(user)
|
||||||
|
|
||||||
|
assert {:ok, %User{}} = Accounts.delete_user(user)
|
||||||
|
|
||||||
|
refute Accounts.get_user_by_email(user.email)
|
||||||
|
refute Repo.get_by(UserToken, token: token)
|
||||||
|
end
|
||||||
|
|
||||||
|
test "deletes the user's attempts" do
|
||||||
|
user = user_fixture()
|
||||||
|
endgame = endgame_fixture()
|
||||||
|
|
||||||
|
assert {:ok, attempt} =
|
||||||
|
Attempts.record_attempt(Scope.for_user(user), endgame, :solved)
|
||||||
|
|
||||||
|
assert {:ok, %User{}} = Accounts.delete_user(user)
|
||||||
|
|
||||||
|
refute Repo.get(Attempt, attempt.id)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
describe "delete_user_session_token/1" do
|
describe "delete_user_session_token/1" do
|
||||||
test "deletes the token" do
|
test "deletes the token" do
|
||||||
user = user_fixture()
|
user = user_fixture()
|
||||||
|
|||||||
@@ -160,6 +160,44 @@ defmodule ChesstrainerWeb.UserLive.SettingsTest do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe "delete account" do
|
||||||
|
setup %{conn: conn} do
|
||||||
|
user = user_fixture()
|
||||||
|
%{conn: log_in_user(conn, user), user: user}
|
||||||
|
end
|
||||||
|
|
||||||
|
test "renders the permanent deletion warning", %{conn: conn} do
|
||||||
|
{:ok, _lv, html} = live(conn, ~p"/users/settings")
|
||||||
|
|
||||||
|
assert html =~ "Delete account"
|
||||||
|
assert html =~ "permanent and cannot be undone"
|
||||||
|
assert html =~ "Nothing can be recovered"
|
||||||
|
end
|
||||||
|
|
||||||
|
test "deletes the user and redirects home", %{conn: conn, user: user} do
|
||||||
|
{:ok, lv, _html} = live(conn, ~p"/users/settings")
|
||||||
|
|
||||||
|
assert {:error, {:redirect, %{to: "/"}}} =
|
||||||
|
result = lv |> element("#delete_account_button") |> render_click()
|
||||||
|
|
||||||
|
refute Accounts.get_user_by_email(user.email)
|
||||||
|
|
||||||
|
{:ok, conn} = follow_redirect(result, conn, ~p"/")
|
||||||
|
assert conn.resp_body =~ "Your account has been deleted."
|
||||||
|
end
|
||||||
|
|
||||||
|
test "logs the deleted user out", %{conn: conn, user: user} do
|
||||||
|
{:ok, lv, _html} = live(conn, ~p"/users/settings")
|
||||||
|
|
||||||
|
lv |> element("#delete_account_button") |> render_click()
|
||||||
|
|
||||||
|
assert {:error, redirect} = live(conn, ~p"/users/settings")
|
||||||
|
assert {:redirect, %{to: path}} = redirect
|
||||||
|
assert path == ~p"/users/log-in"
|
||||||
|
refute Accounts.get_user_by_email(user.email)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
describe "confirm email" do
|
describe "confirm email" do
|
||||||
setup %{conn: conn} do
|
setup %{conn: conn} do
|
||||||
user = user_fixture()
|
user = user_fixture()
|
||||||
|
|||||||
Reference in New Issue
Block a user