diff --git a/projects/cherry-shim/BUILD b/projects/cherry-shim/BUILD
new file mode 100644
index 0000000..fbc4ca7
--- /dev/null
+++ b/projects/cherry-shim/BUILD
@@ -0,0 +1,6 @@
+py_project(
+ name = "cherry-shim",
+ lib_deps = [
+ py_requirement("cherrypy"),
+ ]
+)
diff --git a/projects/cherry-shim/src/python/cherry_shim.py b/projects/cherry-shim/src/python/cherry_shim.py
new file mode 100644
index 0000000..482ada6
--- /dev/null
+++ b/projects/cherry-shim/src/python/cherry_shim.py
@@ -0,0 +1,28 @@
+#!/usr/bin/env python3
+
+# Import CherryPy
+import cherrypy
+
+
+def shim(app):
+ # Mount the application
+ cherrypy.tree.graft(app, "/")
+
+ # Unsubscribe the default server
+ cherrypy.server.unsubscribe()
+
+ # Instantiate a new server object
+ server = cherrypy._cpserver.Server()
+
+ def _run(host="0.0.0.0", port=8080, pool_size=16):
+ # Configure the server object
+ server.socket_host = host
+ server.socket_port = port
+ server.thread_pool = pool_size
+ server.subscribe()
+ cherrypy.engine.start()
+ cherrypy.engine.block()
+
+ server.run = _run
+
+ return server
diff --git a/projects/tentacles/BUILD b/projects/tentacles/BUILD
index 83b47df..4305c05 100644
--- a/projects/tentacles/BUILD
+++ b/projects/tentacles/BUILD
@@ -4,6 +4,7 @@ py_project(
main_deps = [
"//projects/anosql",
"//projects/anosql-migrations",
+ "//projects/cherry-shim",
py_requirement("click"),
py_requirement("flask"),
py_requirement("jinja2"),
diff --git a/projects/tentacles/config.toml b/projects/tentacles/config.toml
deleted file mode 100644
index 2e4c34c..0000000
--- a/projects/tentacles/config.toml
+++ /dev/null
@@ -1,10 +0,0 @@
-SECRET_KEY = "SgvzxsO5oPBGInmqsyyGQWAJXkS9"
-UPLOAD_FOLDER = "/home/arrdem/Documents/hobby/programming/source/projects/tentacles/tmp"
-
-[db]
-uri = "/home/arrdem/Documents/hobby/programming/source/projects/tentacles/tentacles.sqlite3"
-
-[[users]]
-email = "root@tirefireind.us"
-group_id = 0
-status_id = 1
diff --git a/projects/tentacles/src/python/tentacles/__main__.py b/projects/tentacles/src/python/tentacles/__main__.py
index 30c6bf3..506aa0a 100644
--- a/projects/tentacles/src/python/tentacles/__main__.py
+++ b/projects/tentacles/src/python/tentacles/__main__.py
@@ -8,6 +8,8 @@ import tomllib
import click
from flask import Flask, request
+
+from cherry_shim import shim
from tentacles.blueprints import (
api,
file_ui,
@@ -102,10 +104,11 @@ def serve(hostname: str, port: int, config: Path):
# Shove our middleware in there
app.wsgi_app = custom_ctx(app, app.wsgi_app)
+ cherry = shim(app)
# And run the blame thing
try:
- app.run(host=hostname, port=port)
+ cherry.run(host=hostname, port=port)
finally:
shutdown_event.set()
diff --git a/projects/tentacles/src/python/tentacles/globals.py b/projects/tentacles/src/python/tentacles/globals.py
index 896818a..5470d7c 100644
--- a/projects/tentacles/src/python/tentacles/globals.py
+++ b/projects/tentacles/src/python/tentacles/globals.py
@@ -15,6 +15,7 @@ class Ctx:
sid: str = None
username: str = None
is_admin: bool = None
+ base_url: str = None
_ctx = ContextVar("tentacles.ctx")
diff --git a/projects/tentacles/src/python/tentacles/schema.sql b/projects/tentacles/src/python/tentacles/schema.sql
index c6275f5..b2ec1db 100644
--- a/projects/tentacles/src/python/tentacles/schema.sql
+++ b/projects/tentacles/src/python/tentacles/schema.sql
@@ -14,8 +14,9 @@ CREATE TABLE IF NOT EXISTS user_statuses (
, UNIQUE(name)
);
-INSERT OR IGNORE INTO user_statuses (id, name) VALUES (-1, 'disabled');
+INSERT OR IGNORE INTO user_statuses (id, name) VALUES (-3, 'unapproved');
INSERT OR IGNORE INTO user_statuses (id, name) VALUES (-2, 'unverified');
+INSERT OR IGNORE INTO user_statuses (id, name) VALUES (-1, 'disabled');
INSERT OR IGNORE INTO user_statuses (id, name) VALUES (1, 'enabled');
CREATE TABLE IF NOT EXISTS users (
@@ -25,7 +26,9 @@ CREATE TABLE IF NOT EXISTS users (
, email TEXT
, hash TEXT
, status_id INTEGER
+ , verification_token TEXT DEFAULT (lower(hex(randomblob(32))))
, verified_at TEXT
+ , approved_at TEXT
, enabled_at TEXT
, FOREIGN KEY(group_id) REFERENCES groups(id)
, FOREIGN KEY(status_id) REFERENCES user_statuses(id)
@@ -61,6 +64,7 @@ CREATE TABLE IF NOT EXISTS printers (
id INTEGER PRIMARY KEY AUTOINCREMENT
, name TEXT
, url TEXT
+ , stream_url TEXT
, api_key TEXT
, status_id INTEGER
, last_poll_date TEXT
diff --git a/projects/tentacles/src/python/tentacles/templates/verification_email.html.j2 b/projects/tentacles/src/python/tentacles/templates/verification_email.html.j2
new file mode 100644
index 0000000..814f148
--- /dev/null
+++ b/projects/tentacles/src/python/tentacles/templates/verification_email.html.j2
@@ -0,0 +1,40 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Welcome {{ username }}!
+
+
+ Before you can use your account, please confirm your email address by clicking this link or pasting the following text into your browser's navigation bar.
+